home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / wordproc / hshell1.arj / TUTOR.DOC < prev    next >
Text File  |  1993-12-29  |  147KB  |  3,961 lines

  1.  
  2.  
  3.  
  4.        HyperShell Users Guide                        The HyperShell language
  5.  
  6.  
  7.  
  8.  
  9.                            The HyperShell language
  10.  
  11.  
  12.  
  13.        4. HyperShell language
  14.  
  15.        HyperShell language uses a terse form of specification which gives the
  16.        impression that it is more complicated than it really is.  To achieve
  17.        simple results, simple commands are used.  As more power is required,
  18.        additional commands and command structures can be learnt.  There is
  19.        very little initial learning curve.
  20.  
  21.        This chapter is intended as a tutorial to lead you through the
  22.        fundamentals of HyperShell file structure and programming.  Whilst you
  23.        are reading this, you should experiment with producing your own file.
  24.  
  25.        4.1 The basic hyperfile
  26.  
  27.        A basic hyperfile consists of a simple text file split into frames by
  28.        lines starting with:-
  29.  
  30.          .FRAME frame name
  31.  
  32.        The text after this line is displayed when the frame is current.  If
  33.        the text takes more than one screenfull, it is displayed as `pages',
  34.        and HyperShell allows the user to page forward and backward through
  35.        the frame text.  If the text is not split at a suitable point, a
  36.        screen break can be inserted at the end of the last line to appear on
  37.        the first page.  This takes the form:-
  38.  
  39.          ~G
  40.  
  41.        The basic reference found in frame texts is the frame reference.  This
  42.        is of the form:-
  43.  
  44.          ~Fframe name~E.
  45.  
  46.        This, when selected, causes the frame named to replace the currently
  47.        displayed frame.
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                        - 29 -
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.        The HyperShell language                       HyperShell Users Guide
  71.  
  72.  
  73.          +--------------------------------------+
  74.          |.FRAME frame one                      |
  75.          |  A reference to ~Fframe two~E and    |
  76.          |  one to ~Fframe three~E in this      |
  77.          |  frame.                              |
  78.          |.FRAME frame two                      |
  79.          |  This just contains a reference to   |
  80.          |  ~Fframe three~E in it.              |
  81.          |.FRAME frame three                    |
  82.          |  This contains a reference to        |
  83.          |  both ~Fframe one~E and also to      |
  84.          |  ~Fframe two~E~G                     |
  85.          |  This text appears on a second page  |
  86.          |.END                                  |
  87.          +--------------------------------------+
  88.  
  89.        A substantial hyperfile can be built from the structures described so
  90.        far.  Additional ease of use and the presentation and appearance of
  91.        the application are among the benefits of utilising further structures
  92.        and facilities.  Additional functionality for diverse applications is
  93.        also available.
  94.  
  95.        4.1.1 Actions
  96.  
  97.        The `action' is the HyperShell equivalent of a `command' in a normal
  98.        programming language.  An action is a command string which causes an
  99.        action to be taken.  The action to be taken is specified by the first
  100.        character (or the first two characters) of the action string.  The
  101.        parameters or operands of an action are supplied by the remainder of
  102.        the action string.  This part of the string can be supplied literally
  103.        (ie. as a text string), or can be supplied as the result of a
  104.        `function', which is called an `action modifier' in HyperShell
  105.        parlance.  An action string cannot contain a space between the action
  106.        code and the parameter.  Actions can be used in a number of places:-
  107.  
  108.          1.  In a reference in the text.
  109.          2.  As a menu action.
  110.          3.  In a script.
  111.  
  112.        The basic HyperShell `action' to achieve a jump to a new frame takes
  113.        the form:-
  114.  
  115.          Fframe name
  116.  
  117.        It can be seen that this is very similar to the frame reference
  118.        structure which achieves the same result.
  119.  
  120.        If the reference text does not contain the precise name of the frame,
  121.        we can code this action explicitly in the reference. eg. :-
  122.  
  123.          ~Ffelines~PFthe cat~E
  124.  
  125.        Here, the word `felines' appears highlighted in the text, but the
  126.        frame `the cat' is displayed when it is selected.
  127.  
  128.  
  129.                                        - 30 -
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.        HyperShell Users Guide                        The HyperShell language
  137.  
  138.  
  139.        4.1.2 Global items
  140.  
  141.        Global items are general to the hyperfile, and they are placed at the
  142.        start of the hyperfile, before the first frame.  The most common
  143.        global item is the NOTE.  A number of notes can appear in the
  144.        hyperfile.  Each one consists of a line starting:-
  145.  
  146.          .NOTE note name
  147.  
  148.        This is followed by the text for the note.  The displayed note text
  149.        cannot be larger than 22 lines of 77 characters.
  150.  
  151.        Note text can contain references to other notes, to frames, or to
  152.        other types of action.
  153.  
  154.        A note is referenced in frame or note text by the following form:-
  155.  
  156.          ~Nnote name~E
  157.  
  158.        You will notice that this is similar to the frame reference.  As in
  159.        the frame reference, an explicit reference can be added using the ~P
  160.        flag.  This need not be a note action, although it is obviously less
  161.        confusing to the user if it is.  It could, however, run a script which
  162.        eventually displays a note.  The action to display a global note is
  163.        simply:-
  164.  
  165.          Nnote name
  166.  
  167.        4.1.3 Local items
  168.  
  169.        Local items are notes, menus and scripts which can only be accessed
  170.        from a specific frame.  As such, they are coded after the frame in the
  171.        hyperfile, and before the next frame.  The local note is coded in the
  172.        same way as the global note.
  173.  
  174.        The local note is referenced in the frame using the following form:-
  175.  
  176.          ~nnote name~E
  177.  
  178.        Note that the flag is a lowercase `n'.  Local versions of menus and
  179.        scripts also use the lowercase letter.
  180.  
  181.        The action to display a local note is as expected:-
  182.  
  183.        nnote name
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                        - 31 -
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.        The HyperShell language                       HyperShell Users Guide
  203.  
  204.  
  205.          +--------------------------------------+
  206.          |.NOTE cat                             | global
  207.          |  (Moggus lazius) Small feline        |
  208.          |  quadruped. Has a liking for fish,   |
  209.          |  warmth, and sleep.                  |
  210.          |.NOTE dog                             | global
  211.          |  (Gnashus noisius) Medium size       |
  212.          |  quadruped. Likes barking, fetching  |
  213.          |  sticks and eating leftovers.        |
  214.          |.FRAME Pets                           | frame
  215.          |  Apart from the usual domestic       |
  216.          |  pets, the ~Ncat~E and the ~Ndog~E,  |
  217.          |  the next most popular is the        |
  218.          |  ~nhamster~E, which needs the        |
  219.          |  minimum of maintenance, and is a    |
  220.          |  lovable creature, apart from when   |
  221.          |  it bites.                           |
  222.          |.NOTE hamster                         | local
  223.          |  (Mus stupidus)                      |
  224.          |  Tiny rodent quadruped.              |
  225.          |  Likes running in a wheel all        |
  226.          |  night and eating carrots.           |
  227.          |.END                                  |
  228.          +--------------------------------------+
  229.  
  230.        4.1.4 The frame display format
  231.  
  232.        The straightforward hyperfile design described above, along with the
  233.        HyperShell reader, provides a full traditional hypertext system.
  234.        Large hyperfiles using just these simple rules can be constructed.
  235.  
  236.        Normally, however, it is desirable to enhance the appearance of the
  237.        hyperfile, and to provide features to assist with the operation of the
  238.        system.
  239.  
  240.        The appearance of the information is not limited to the frame text.
  241.        Just as a book has running headings and footings, so the HyperShell
  242.        screen can have header and footer information which appears on every
  243.        screen.
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.                                        - 32 -
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.        HyperShell Users Guide                        The HyperShell language
  269.  
  270.  
  271.           Frame display format
  272.          +--------------------------------------------+
  273.          | --- HEADER TEXT -------------------------- |
  274.          | ------------------------------------------ |
  275.          |                                            |
  276.          |                                            |
  277.          |      FRAME TEXT                            |
  278.          |                                            |
  279.          |                                            |
  280.          |                                            |
  281.          |                                            |
  282.          |                                            |
  283.          | --- FOOTER TEXT -------------------------- |
  284.          | ------------------------------------------ |
  285.          | === MESSAGE AND PROMPT LINE ============== |
  286.          +--------------------------------------------+
  287.  
  288.        4.1.5 The Header
  289.  
  290.        The HEADER item, provided at the start of the global items, provides
  291.        the text which will appear at the top of every screen.  A line of the
  292.        form:-
  293.  
  294.          .HEADER
  295.  
  296.        is followed by one or more lines containing the text which will appear
  297.        at the top.  If a HEADER is not supplied, a default header showing the
  298.        frame name and the title is used.  The header text, as well as frame
  299.        text and note text, can contain `variable tokens' which are replaced
  300.        by their values when the text is displayed.  These take the form:-
  301.  
  302.          $x
  303.  
  304.        where x is the variable name.  Standard `system' variables exist which
  305.        provide specific variable items.  Two of these are the frame name held
  306.        in variable 1 and the frame title held in variable 2.  Our header
  307.        might therefore look like:-
  308.  
  309.          +--------------------------------------------+
  310.          |.HEADER                                     |
  311.          | Frame: $1                                  |
  312.          | Title: $2                                  |
  313.          +--------------------------------------------+
  314.  
  315.        This simply displays the two lines at the top of each frame, with $1
  316.        replaced by the frame name and $2 replaced by the frame title.
  317.  
  318.        A `null' header consists of a .HEADER line followed by another line
  319.        starting with a `.'.  This may be used if each frame is to have a
  320.        different format, and does not need the default title.
  321.  
  322.        The header display can be suppressed for specific frames by starting
  323.        the frame title with a `)' character.
  324.  
  325.  
  326.  
  327.                                        - 33 -
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.        The HyperShell language                       HyperShell Users Guide
  335.  
  336.  
  337.        4.1.6 The Footer
  338.  
  339.        The FOOTER is coded in a similar manner to the HEADER, starting with a
  340.        line as follows:-
  341.  
  342.          .FOOTER
  343.  
  344.        This is followed by one or more lines, which will appear after the
  345.        frame text at the bottom of each screen when the frame text is being
  346.        displayed.  It is displayed immediately after the frame text, so we
  347.        generally force it to appear on a specific line using a `formatting
  348.        flag' in the text.  A flag of the form:-
  349.  
  350.          ~L22    . . . .  Footer Text . . . .
  351.  
  352.        will cause the text on the line to appear on line 22 of the frame.  In
  353.        a similar fashion, it is possible to use a formatting flag to place
  354.        text at a column position, using the ~C flag.
  355.  
  356.          +--------------------------------------------------+
  357.          |.FOOTER                                           |
  358.          |~L22~C15~APress space bar for next frame~PF+~K ~E |
  359.          +--------------------------------------------------+
  360.  
  361.        This displays a selectable reference on line 22, column 15 which can
  362.        be selected using the mouse cursor or by pressing the space bar.  The
  363.        space character is mapped to the reference, and the parameter section
  364.        provides the `F+' action, which causes the next frame to be displayed.
  365.        It is also possible to step through so that no backtrack information
  366.        is retained.  This is done using the lowercase form of the reference
  367.        (f+).
  368.  
  369.        The footer can contain the same kind of information that the header
  370.        contains, and is often used to display the function key mappings.
  371.  
  372.        4.1.7 Popup menus
  373.  
  374.        The popup menu is a useful addition.  It allows a concise list of
  375.        choices to be readily presented for selection.  The action resulting
  376.        from making a selection can be any HyperShell action.  For instance, a
  377.        list of related frames can be offered from a frame, or a menu of help
  378.        notes can be offered when a function key is pressed.
  379.  
  380.        The footer could contain a reference to a `See Also' menu, which
  381.        contains a list of related frames.
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                        - 34 -
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.        HyperShell Users Guide                        The HyperShell language
  401.  
  402.  
  403.          +-------------------------------------------------+
  404.          |.FOOTER                                          |
  405.          |~L22   ~mSee Also~E                              |
  406.          |    - - Other items and frames - -               |
  407.          |.FRAME Hamsters                                  |
  408.          | - - frame text - -                              |
  409.          |.MENU See Also                                   |
  410.          |Mice                                             |
  411.          |Gerbils                                          |
  412.          |Rats                                             |
  413.          |Guinea Pigs                                      |
  414.          |Wombats                                          |
  415.          +-------------------------------------------------+
  416.  
  417.        Of course, not all frames will have a `See Also' menu.  When a local
  418.        item is not available, HyperShell first looks for a global item of the
  419.        same name.  This allows us to have a global `catch all' menu in this
  420.        case.
  421.  
  422.          +------------------------------------------+
  423.          |.MENU See Also                            |
  424.          |Introduction                              |
  425.          |Pets                                      |
  426.          |Rodents                                   |
  427.          +------------------------------------------+
  428.  
  429.        4.1.8 Conditional text
  430.  
  431.        Perhaps there is no sensible global item which can be used, and we
  432.        really only want those frames with a local item to reference it.
  433.        There is a way of achieving this using `conditional text' in the
  434.        footer, which can be turned on or off as required for each frame. If
  435.        the footer looks like:-
  436.  
  437.          +-----------------------------------------+
  438.          |.FOOTER                                  |
  439.          |~h6~L22  ~mSee Also~E                    |
  440.          +-----------------------------------------+
  441.  
  442.        Then the menu reference will only be displayed if frame-local flag 6
  443.        is set.  This flag can be set within the frame text for a frame using
  444.        the flag:-
  445.  
  446.          ~J6
  447.  
  448.        where 6 represents the local condition name in this case.  This flag
  449.        should appear near the start of the frame text for each frame which
  450.        has the local menu.
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                        - 35 -
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.        The HyperShell language                       HyperShell Users Guide
  467.  
  468.  
  469.        4.1.9 Help menu
  470.  
  471.        A simple help facility is probably the first feature you will want to
  472.        add to your system.  The `?' key is by default mapped to a global menu
  473.        called `help', which must only contain global note actions.  This may
  474.        be used for a simple help system.  Note that this form of help is
  475.        available from the paged display screen as well.
  476.  
  477.        The help system may be used to describe the operation of HyperShell
  478.        and any specific operational aspects of the hyperfile, or can be used
  479.        in support of the main hyperfile material.  The hyperfile could have a
  480.        simple system describing how to use simple navigation in HyperShell.
  481.        To add this to your hyperfile, insert a global menu called `help' as
  482.        follows:-
  483.  
  484.          +--------------------------------------+
  485.          |.MENU Help                            |
  486.          |Selecting      |NSelecting            |
  487.          |Control keys   |NControl keys         |
  488.          +--------------------------------------+
  489.  
  490.        and some global notes as follows:-
  491.  
  492.          +--------------------------------------+
  493.          |.NOTE Selecting                       |
  494.          |You can follow references to          |
  495.          |move between frames and to            |
  496.          |display popup notes and menus.        |
  497.          |To select a reference position        |
  498.          |the mouse cursor using the mouse,     |
  499.          |cursor keys or TAB and SHIFT/TAB,     |
  500.          |then select by pressing ENTER,        |
  501.          |or the LEFT mouse button.             |
  502.          +--------------------------------------+
  503.  
  504.          +--------------------------------------+
  505.          |.NOTE Control keys                    |
  506.          |You can use the function keys to      |
  507.          |control the system. The function      |
  508.          |keys are setup as follows:-           |
  509.          |                                      |
  510.          |F1  - Go to introductory frame        |
  511.          |F2  - Display contents of file        |
  512.          |F3  - Move back to previous reference |
  513.          |F4  - Move back a number of steps     |
  514.          |F5  - Display list of noted frame     |
  515.          |F6  - Search file for text string     |
  516.          |F7  - Display contents of text file   |
  517.          |F8  - Perform requested action        |
  518.          |F9  - Temporary exit to DOS           |
  519.          |F10 - Quit to DOS                     |
  520.          +--------------------------------------+
  521.  
  522.        This provides a fairly simple help system.
  523.  
  524.  
  525.                                        - 36 -
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.        HyperShell Users Guide                        The HyperShell language
  533.  
  534.  
  535.        4.1.10 The SETUP script
  536.  
  537.        To provide further features in a help system, the F1 key can be mapped
  538.        to provide the help menu.  More complex interaction with the help
  539.        system is then possible, and the help menu is not limited to simple
  540.        note references.
  541.  
  542.        To do this, you will need to create a SETUP script.  The SETUP script
  543.        is run whenever the hyperfile is `entered' which is usually on start-
  544.        up when running HyperShell against the file.  It will also be executed
  545.        if you select a reference to this hyperfile from another hyperfile.
  546.        It can therefore be used to set up any key mappings, colour schemes,
  547.        options etc.  required by a hyperfile.
  548.  
  549.        The SETUP script is simply a global script with the name `SETUP'.  To
  550.        set up the F1 key on the control menu, this would be as follows:-
  551.  
  552.          +---------------------------------------+
  553.          |.SCRIPT SETUP                          |
  554.          |KF1MHelp                               |
  555.          |KM1Help                                |
  556.          +---------------------------------------+
  557.  
  558.        The first line maps the F1 key to the action `MHelp', which invokes
  559.        the global menu called `Help' which we created above.
  560.  
  561.        The second line changes the text of the control menu for the F1 action
  562.        to be `Help', rather than the default of `Home Frame'.
  563.  
  564.        Note that frame, note, menu and script names are not sensitive to
  565.        whether the name is in uppercase or lowercase or mixed case, and
  566.        references can use cases different to the item names.
  567.  
  568.        4.1.11 The NDEX
  569.  
  570.        When a hyperfile grows beyond a certain size (about 30k to 50k), it is
  571.        preferable to use the automatic index facilities.  An index file is
  572.        used to save HyperShell from having to read all the way through the
  573.        hyperfile to build its internal index.  Opening and reading the index
  574.        file has its own overheads, however, so the index should not be
  575.        specified for small hyperfiles.
  576.  
  577.        The index file is maintained automatically.  If you modify the
  578.        hyperfile, HyperShell will rebuild the index for you.
  579.  
  580.        The index is specified using the .INDEX directive.  The .INDEX line
  581.        should be present anywhere before the first frame specification.  This
  582.        specifies that an index file is to be created and maintained for the
  583.        hyperfile.
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.                                        - 37 -
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.        The HyperShell language                       HyperShell Users Guide
  599.  
  600.  
  601.        4.1.12 Supporting text files
  602.  
  603.        Normal text files, and files with just reference flags in them, can be
  604.        used in support of the hyperfile in two ways.  The F7 key allows a
  605.        filename to be entered, and displays the text file allowing the user
  606.        to page backward and forward and do text searches.  The F7 key is
  607.        mapped to action code `T'.  The `T' action can also be called from a
  608.        reference in the text.  This reference takes the form:-
  609.  
  610.          ~Ahighlighted text~PTfilename.ext~E
  611.  
  612.        The text `highlighted text' will appear as a highlighted reference in
  613.        a frame or note display, and when selected will cause the file
  614.        `filename.ext' to be displayed.  This file may contain embedded
  615.        references to the frames in the hyperfile.  One way to achieve this is
  616.        to do it automatically when displaying the file, rather than having to
  617.        actually modify the file.  This is known as automatic referencing (or
  618.        `autoreferencing').  To enable this, the line:-
  619.  
  620.          O41
  621.  
  622.        should be added to the SETUP script (this starts with the letter O,
  623.        not the figure 0). When this is done, an occurrence in the text file
  624.        of any of the frame names would be highlighted when the file was
  625.        displayed, and could be selected, whereupon the relevant frame would
  626.        be displayed.  After the frame is read, and possibly after the user
  627.        has moved to other frames, the file display can be continued by simply
  628.        pressing the F7 key.  This will call the action `T' without a file
  629.        name parameter, which causes HyperShell to resume viewing the text
  630.        file at the point it was when the frame name was selected.
  631.  
  632.        Another way that text files may be used in support of a hyperfile is
  633.        the `file note'.  A reference of the form:-
  634.  
  635.          ~tfilename~E
  636.  
  637.        refers to a file called `filename.nte' which is displayed as a popup
  638.        note when the reference is selected.  Note that the extension `.NTE'
  639.        is added only if one is not supplied in the reference, so for instance
  640.        if we had a file called `feeding.txt' we could have a reference of the
  641.        form:-
  642.  
  643.          ~tnourishment~Ptfeeding.txt~E
  644.  
  645.        Note that this uses the action code `t', which has the same effect as
  646.        the `~t' reference flag.
  647.  
  648.        4.1.13 The menu bar
  649.  
  650.        If the top line of a frame display (usually part of the Header)
  651.        contains menu references, these can be made to immediately be selected
  652.        if the mouse cursor moves over them.  This is controlled by setting
  653.        flag 4 in option 1 as follows:-
  654.  
  655.  
  656.  
  657.                                        - 38 -
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.        HyperShell Users Guide                        The HyperShell language
  665.  
  666.  
  667.          O14
  668.  
  669.        Note that option 1 has a number of flags which can be set, as
  670.        follows:-
  671.  
  672.          Option 1 - flag mask values
  673.          +---------------------------------------------+
  674.          | 1 | Show symbols to indicate actions        |
  675.          | 2 | Use first letter, not function keys     |
  676.          | 4 | Menu refs on top line are immediate     |
  677.          +---------------------------------------------+
  678.  
  679.        These flags have mask values of 1, 2 and 4, and you should add
  680.        together the flag values to form the option value.  For instance, if
  681.        we wanted to display menu symbols as well as have immediate menus on
  682.        the top line, but we wanted function key selections on menus rather
  683.        than first letter selection, we would add the flag values 1 and 4
  684.        together to form the value 5, then set option 1 to 5:-
  685.  
  686.          O15
  687.  
  688.        Many systems, including graphic user interface packages, have
  689.        `pulldown menus' selectable from a menu bar at the top of the window
  690.        or screen.  A menu bar can be easily created in HyperShell by setting
  691.        up a string of menu references on the top line, and optionally making
  692.        them `immediate' using the above option setting.  The natural place to
  693.        set this up is in the Header item, although a situation could exist
  694.        where no header was specified, and each frame had its own custom menu
  695.        bar.  A typical Header might look like:-
  696.  
  697.          +--------------------------------------------------+
  698.          |.HEADER                                           |
  699.          | ~MFile~Kf~E ~MEdit~Ke~E ~MHelp~Kh~E              |
  700.          +--------------------------------------------------+
  701.  
  702.        This gives access to three global menus for file operations, edit
  703.        operations and for help. These menus are mapped to the keys `f', `e'
  704.        and `h'.  This is not essential, but gives the user an extra method of
  705.        selecting the options.  Note that if the key mappings are used, these
  706.        keys cannot be mapped in the frame text.
  707.  
  708.        If the key mappings are in effect, it would be nice to indicate that
  709.        they are available. This can be done by highlighting the initial
  710.        letter differently to the rest of the word.  We can embed formatting
  711.        flags to achieve this:-
  712.  
  713.          +--------------------------------------------------+
  714.          |.HEADER                                           |
  715.          | ~M~TwF~TKile~Kf~E ~M~TwE~TK~dit~Ke~E . etc .     |
  716.          +--------------------------------------------------+
  717.  
  718.        Note that the formatting flags are not used in the construction of the
  719.        menu name from the reference.
  720.  
  721.  
  722.  
  723.                                        - 39 -
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.        The HyperShell language                       HyperShell Users Guide
  731.  
  732.  
  733.        4.1.14 Input fields
  734.  
  735.        One particularly useful form of reference of general use is the input
  736.        field.  This takes the form of a highlighted reference until it is
  737.        selected.  When this is done, it becomes a string input area which can
  738.        be used for input and editing of data.  The input field is set up
  739.        using flags in the following general form:-
  740.  
  741.          ~Iinput area~Paction template~E
  742.  
  743.        The input area is usually filled with spaces, or with the contents of
  744.        a variable.  To allow sufficient room to enter a long enough string, a
  745.        width specified is usually added.
  746.  
  747.        The action template is an action or multiple action containing up to
  748.        three `%s' tokens.  When the input is completed by pressing the RETURN
  749.        key, the value on display is substituted in the place of each token,
  750.        then the actions are performed.  The first action is usually a
  751.        variable assignment.  Other actions, such as a call to a validation
  752.        script, are usually coded afterwards.  An example of an input field
  753.        would be specified as follows:-
  754.  
  755.          +---------------------------------------------+
  756.          | . . .                                       |
  757.          |    ~I$N~W20~PVN%s;sCheck N~E                |
  758.          | . . .                                       |
  759.          +---------------------------------------------+
  760.  
  761.        This displays a field 20 characters wide containing the current value
  762.        of variable N.  When the field is selected, the value may be edited.
  763.        When the RETURN key is pressed, the value is assigned to variable N
  764.        and the local script called `Check N' is called to validate the value
  765.        entered.
  766.  
  767.        Notes can use an input field to act as a dialogue box, and frames can
  768.        use a number of input fields to act as a data entry form.
  769.  
  770.        4.2 Programming
  771.  
  772.        This section introduces the fundamental concepts necessary to write
  773.        complex actions and scripts using HyperShell.  As many people are
  774.        familiar with the BASIC interpretive language, the corresponding
  775.        constructs in BASIC are also included in some cases as an aid to
  776.        understanding.
  777.  
  778.        Because of the multiplicity of variations of the actions and codes
  779.        described, it is not practical or necessary to cover every variation.
  780.        The fundamentals are described here, and the reference guides should
  781.        be consulted for information on the other variations of facility
  782.        provided.
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.                                        - 40 -
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.        HyperShell Users Guide                        The HyperShell language
  797.  
  798.  
  799.        4.2.1 Action modifiers
  800.  
  801.        As we saw above, actions are the HyperShell equivalent of commands in
  802.        other programming languages.
  803.  
  804.        Action modifiers are the equivalent of functions, and provide the
  805.        parameter value for an action.  One type of action modifier is the
  806.        dynamic menu which is a menu or other selection item.  This can be a
  807.        normal menu or can be one built dynamically at the time you run it.
  808.        For example, to set the variable to a value chosen from a menu, the
  809.        action would be:-
  810.  
  811.          Va@Mnames
  812.  
  813.        This would popup the menu called `names' to allow one of a set of
  814.        names to be selected by the user.  The selected name would replace the
  815.        modifier string in the action before it was executed.
  816.  
  817.        Dynamic menus start with the `@' sign, and have a single character
  818.        identifying what kind of menu they are, sometimes followed by a
  819.        parameter string.
  820.  
  821.        Dynamic menus can have other action modifiers `cascaded' to give
  822.        complex interaction functionality.  For example, to type a file
  823.        selected from a menu formed from a directory listing of files with a
  824.        wildcard specification input from the user, the action would be:-
  825.  
  826.          T@d?Wildcard specification
  827.  
  828.        This would prompt the user for a wildcard specification, which would
  829.        be used to select files from the current directory to form a menu from
  830.        which the user could select a file to type.
  831.  
  832.        The `?' sign introduces another kind of action modifier called a
  833.        prompt. This has prompt string parameter which is displayed as a
  834.        prompt. The string the user types in response to the prompt will be
  835.        returned and will replace the prompt action modifier in the action
  836.        string.
  837.  
  838.        If the result of an action modifier is not usable in its provided
  839.        state, it can be further formatted using a format string:-
  840.  
  841.          D@d*.DAT|COPY %s A:%s
  842.  
  843.        This would present a menu of all files with the extension .DAT in the
  844.        current directory, and would then copy the selected file to the A:
  845.        drive.  The resulting action string would take the form:-
  846.  
  847.          DCOPY FRED.DAT A:FRED.DAT
  848.  
  849.        The `d' dynamic menu is used to display a popup directory listing of
  850.        files matching a wildcard specification.  It returns the name of the
  851.        selected file.
  852.  
  853.  
  854.  
  855.                                        - 41 -
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.        The HyperShell language                       HyperShell Users Guide
  863.  
  864.  
  865.        The `|' symbol separates the action string from the format string.
  866.        The format string can contain one, two or three `%s' tokens, which are
  867.        replaced by the action modifier value before the value is replaced in
  868.        the action string.
  869.  
  870.        4.2.2 Multiple actions
  871.  
  872.        We have already seen how actions can be put together in a string.
  873.        Here are some rules about multiple actions:-
  874.  
  875.        1. The condition of a conditional action affects remaining actions.
  876.        2. A conditional jump does not clear remaining actions.
  877.        3. The remaining actions in a multiple action are cleared if an error
  878.        occurs in an action, or an input is cancelled.
  879.        4. If a further multiple action is encountered, for instance as the
  880.        result of an action modifier or menu selection, the remaining actions
  881.        are cleared in the original.
  882.  
  883.        4.2.3 Variables
  884.  
  885.        Most programming languages and programmable systems support the
  886.        concept of variables.  A variable is a container for variable
  887.        information.  Variables can be thought of as boxes with names on them.
  888.        You can store strings of characters and numbers in variables.
  889.        HyperShell has a number of different types of variable.  The common
  890.        variables have single letter names, there being 52 of these using both
  891.        uppercase and lowercase letters.
  892.  
  893.        Variables do not need to be declared, and come into existence by
  894.        assignment.  Single letter variables are assigned using the `V'
  895.        action, and take the value of the remaining text in the action string.
  896.        e.g.
  897.  
  898.          Vafred      (BASIC LET a = "fred")
  899.  
  900.        assigns the value `fred' to the variable `a'. The variable can have
  901.        another value subsequently assigned to it, or it can be cleared by use
  902.        of a null string (a string of zero length):-
  903.  
  904.          Va
  905.  
  906.        4.2.4 Named Variables
  907.  
  908.        The set of common variables may be used for most purposes in
  909.        HyperShell.  There are cases where more than the 52 common variables
  910.        are required, and HyperShell allows an application to specify any
  911.        number of another form of variable, called a named variable.  These
  912.        have any name which contains valid characters, and the name can
  913.        contain spaces.  Examples of valid names are:-
  914.  
  915.          price
  916.          size of field
  917.          RS232
  918.          47>aj 9-c
  919.  
  920.  
  921.                                        - 42 -
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.        HyperShell Users Guide                        The HyperShell language
  929.  
  930.  
  931.          Hamster food
  932.  
  933.        Named variables are assigned using the `l' action or the ZV action.
  934.        Using the `l' action, the named variable can only be assigned values
  935.        from single letter variables.  e.g.
  936.  
  937.          laname    (BASIC LET name = a)
  938.  
  939.        The ZV action allows a literal string to be directly assigned to the
  940.        variable:-
  941.  
  942.          ZVname=value
  943.  
  944.        Note that the name in either case can be provided from an action
  945.        modifier, or from a variable token expansion.  e.g.
  946.  
  947.          la$b
  948.  
  949.        This loads the contents of `a' into the variable whose name is the
  950.        contents of variable `b'. There is no equivalent of this in BASIC, or
  951.        any of the other common interpretive languages for that matter.
  952.  
  953.        4.2.5 Variable expansion
  954.  
  955.        The variable may be used in a number of ways.  The most common is as
  956.        an expansion token in the frame or note text, or in an action string
  957.        as above.  The format of the token is:-
  958.  
  959.          $x
  960.  
  961.        where `x' is the variable name.  This token is replaced by the value
  962.        of the named variable, before being used for display or action
  963.        purposes.
  964.  
  965.        The variable can in fact be expanded anywhere in an action string
  966.        after the first letter.  For example, to load the variable whose name
  967.        is a concatenation of the contents of the variables `c' and `d' from
  968.        the single letter variable whose name is contained in variable `x', we
  969.        would write:-
  970.  
  971.          l$x$c$d
  972.  
  973.        The named variable expansion token takes the form:-
  974.  
  975.          $(name)
  976.  
  977.        Where `name' is the name of the named variable.  This itself can be
  978.        supplied by a single letter variable.  e.g.
  979.  
  980.          $($b)
  981.  
  982.        Thus to do the opposite of `la$b' we would write:-
  983.  
  984.          Va$($b)
  985.  
  986.  
  987.                                        - 43 -
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.        The HyperShell language                       HyperShell Users Guide
  995.  
  996.  
  997.  
  998.        Variable token substitution is done in frame and note text before
  999.        displaying the text (so variables can contain reference flags).
  1000.  
  1001.        Variable token substitution is done in action strings AFTER any action
  1002.        modifiers have been actioned and before the action is executed.  Thus
  1003.        an action string of the form:-
  1004.  
  1005.          Vb?value of b
  1006.  
  1007.        could have a value of `$c' typed in by the user, which would be
  1008.        expanded to the contents of variable `c' before the assignment was
  1009.        made.
  1010.  
  1011.        A variable token expansion can be `deferred' one step by putting two $
  1012.        signs.  This will be converted to one $ on the first expansion and
  1013.        will be expanded on the second.  Thus a variable token in an action
  1014.        string in a reference on a frame display should have two $ signs, as
  1015.        the expansion on display would otherwise pre-empt the intended
  1016.        expansion when the reference was actioned.
  1017.  
  1018.        4.2.6 Other uses of variables
  1019.  
  1020.        Single letter variables can be used directly in an integer expression
  1021.        action modifier.  Thus an action of the form:-
  1022.  
  1023.          Va=b+c    (BASIC LET a = b + c)
  1024.  
  1025.        will do as you might expect and add variables `b' and `c' together,
  1026.        placing the result in `a'.
  1027.  
  1028.        Variables can also be used in this manner in tests, thus we can have:-
  1029.  
  1030.          va=b+c+d;je20    (BASIC IF a = b + c + d GOTO 20)
  1031.  
  1032.        4.2.7 Condition codes
  1033.  
  1034.        When a variable comparison is performed, a number of condition codes
  1035.        are set, and can be tested.  If the variable and test string are of
  1036.        numeric content, the comparison is a numeric comparison, otherwise it
  1037.        is a string comparison and works as a lexicographic or ASCII collating
  1038.        sequence string compare.  This example compares variable `a' against
  1039.        23 and jumps to LESS if it is less than 23.
  1040.  
  1041.          va23;jlLESS
  1042.  
  1043.        This example compares variable `n' against `fred' and jumps to FRED if
  1044.        it is equal.
  1045.  
  1046.          vnfred;jeFRED
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.                                        - 44 -
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.        HyperShell Users Guide                        The HyperShell language
  1061.  
  1062.  
  1063.        Also, a substring and superstring compare is done, so that you can
  1064.        test whether the variable is contained within the string, or contains
  1065.        the string.  This sees if variable `e' is one of `one','two','three'
  1066.        and jumps to Lone, Ltwo or Lthree if so:-
  1067.  
  1068.          veone two three;jw$e
  1069.  
  1070.        It is sometimes useful to test whether the variable is defined at all.
  1071.        This sees if variable `j' is defined and jumps to DEFINED if so:-
  1072.  
  1073.          vj;jdDEFINED
  1074.  
  1075.        The conditional jump action `j' is described later.
  1076.  
  1077.        4.2.8 System variables
  1078.  
  1079.        A number of system variables are available, which have numeric and
  1080.        other character names.  Most of these cannot have values explicitly
  1081.        assigned to them, but can be expanded in exactly the same way as
  1082.        single letter variables.  For example, to display the current date, we
  1083.        code the following token in the text to be displayed:-
  1084.  
  1085.          $4
  1086.  
  1087.        4.2.9 Pseudo variables
  1088.  
  1089.        Two pseudo variables are provided to assist with the specification of
  1090.        certain actions.  These have a constant value (and are therefore not
  1091.        VARIABLE).  These are as follows:-
  1092.  
  1093.          $,           This is replaced by the semicolon `;'
  1094.          $!           This is replaced by the format separator `|'
  1095.  
  1096.        4.2.10 String splitting
  1097.  
  1098.        A number of powerful string processing capabilities exist in
  1099.        HyperShell.  These can be used to manipulate data which has been
  1100.        entered by a user, or input from a file.
  1101.  
  1102.        It is often necessary to break a string into, for instance, a number
  1103.        of fields.  Quite often, data is provided in the form of fields
  1104.        separated by a well known character.  Thus a string could have the
  1105.        form "aaaa:bbbbbb:ccc:dd".  This can be split into a number of
  1106.        variables with an action of the form:-
  1107.  
  1108.          es:abcd
  1109.  
  1110.        Where `s' is the variable containing the string, and a,b,c and d are
  1111.        the variables to receive the fields.  In the example above, variable
  1112.        `a' would receive `aaaa', variable `b' would receive `bbbbbb' etc.
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.                                        - 45 -
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.        The HyperShell language                       HyperShell Users Guide
  1127.  
  1128.  
  1129.        4.2.11 Arrays
  1130.  
  1131.        Arrays are sets of variables which can be identified using a variable
  1132.        name and one or more `subscripts' or array indexes.
  1133.  
  1134.        Whilst arrays, as they are known in other programming languages, are
  1135.        not supported in HyperShell as such, some constructs are possible to
  1136.        provide some of the functionality for which arrays are used.
  1137.  
  1138.        Constant arrays can be implemented using a menu, referenced using a
  1139.        dynamic menu action modifier in the form:-
  1140.  
  1141.          Vn@Mnames($v)
  1142.  
  1143.        This uses the value of variable `v' as an index into the set of
  1144.        strings specified in the menu called `names', returning the indexed
  1145.        entry and assigning it to variable `n'.
  1146.  
  1147.        Named variables can have their name supplied using variable tokens or
  1148.        combinations of constant strings and variable tokens.  So, if we
  1149.        wanted to set up the equivalent of an array called month with 12
  1150.        elements containing the names of the calendar months, we could set up
  1151.        variables as follows:-
  1152.  
  1153.          ZVmonth1=January
  1154.          ZVmonth2=February
  1155.          ZV  -etc-
  1156.  
  1157.        To obtain the equivalent of month[a], we could code the token:-
  1158.  
  1159.          $(month$a)
  1160.  
  1161.        We could have done the same when we set up the array, so to rename the
  1162.        month with the subscript supplied by variable `n' to `New month', we
  1163.        code:-
  1164.  
  1165.          ZVmonth$n=New month
  1166.  
  1167.        The variable used as the `subscript' could have had its value set in a
  1168.        loop structure (see later), or by some other event.
  1169.  
  1170.        This facility implements what is known as associative arrays i.e.
  1171.        arrays subscripted by character strings.  So, for instance, we could
  1172.        set up an array of fruit colours as follows:-
  1173.  
  1174.          ZVcolour_banana=yellow
  1175.          ZVcolour_apple=green
  1176.          ZVcolour_plum=purple
  1177.          ZVcolour_orange=orange
  1178.          ZVcolour_strawberry=red
  1179.  
  1180.        Then to display the colour of a fruit in the text, given the type of
  1181.        fruit in variable `f', we code:-
  1182.  
  1183.  
  1184.  
  1185.                                        - 46 -
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.        HyperShell Users Guide                        The HyperShell language
  1193.  
  1194.  
  1195.          $(colour_$f)
  1196.  
  1197.        Note that the underscore is not strictly necessary, but is included in
  1198.        the example to give the variable names a better form.
  1199.  
  1200.        Constant associative arrays can also be set up using menus with
  1201.        entries containing the key string and the associated string, and
  1202.        indexed using the form:-
  1203.  
  1204.          Vs@Msurname[$n]
  1205.  
  1206.        This takes the contents of variable `n' as a key to look up an entry
  1207.        in the menu `surname', returning the action string from the located
  1208.        entry and assigning it to the string `s'.  The menu `surname' could
  1209.        have the following form:-
  1210.  
  1211.          +--------------------+
  1212.          |.MENU surname       |
  1213.          |fred|jones          |
  1214.          |jim|smith           |
  1215.          |nick|taylor         |
  1216.          +--------------------+
  1217.  
  1218.  
  1219.        4.2.12 Application control flags
  1220.  
  1221.        We saw above how comparing a variable set condition codes to indicate
  1222.        the result of the comparison.  These condition codes are available
  1223.        until the next comparison is made, unlike most programming languages
  1224.        which bind the condition result to the comparison in a conditional
  1225.        branch.  Other languages have what are known as BOOLEAN variables.
  1226.        These can be assigned as the result of a comparison and have a value
  1227.        of either TRUE or FALSE.  They can be readily tested, as they form a
  1228.        complete condition in themselves.  HyperShell, as well as retaining
  1229.        the condition codes from a comparison, has a set of boolean variables
  1230.        called application control flags.  These can be used directly as
  1231.        condition codes in all forms of conditional operation.
  1232.  
  1233.        The application control flags have names of A to Z, and can be used to
  1234.        hold single character values.  If the value is null, the flag is
  1235.        regarded as FALSE.  If the value is other than null, the flag is
  1236.        regarded as TRUE.
  1237.  
  1238.        To assign a value to an application control flag, the O*X action is
  1239.        used, where X is a letter A to Z. The assignment takes the form:-
  1240.  
  1241.          O*A1    - to set flag `A' to `1' -condition TRUE
  1242.        or
  1243.          O*A     - to clear flag `A' - condition FALSE
  1244.  
  1245.        This can then be used in a conditional action, or anywhere else a
  1246.        condition can be used. For example:-
  1247.  
  1248.          aAPFlag A is set  - Pops up a message if the flag is set
  1249.  
  1250.  
  1251.                                        - 47 -
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.        The HyperShell language                       HyperShell Users Guide
  1259.  
  1260.  
  1261.  
  1262.        The value can of an application control flag can be obtained using the
  1263.        &O function as follows:-
  1264.  
  1265.          Vx&OA   - Set variable `x' to character value of A
  1266.  
  1267.        4.2.13 Uses of condition codes
  1268.  
  1269.        The comparison conditions and the application control flags have been
  1270.        described above.  Also the section on Footers introduced the frame-
  1271.        local flags which are local to a particular frame.  There are other
  1272.        condition codes of a global nature which may be used to determine
  1273.        various things, such as whether an error has occurred during an action
  1274.        modifier, or whether a selection has been made from a menu.  Also
  1275.        there are some conditions which are local to frames such as whether
  1276.        the frame matched the last search operation or whether the frame has
  1277.        been visited before.
  1278.  
  1279.        Conditions can be used in a number of different places.
  1280.  
  1281.        Conditional text
  1282.  
  1283.        We have seen local flags used for conditional display of text in the
  1284.        Footer.  The comparison conditions, the application control flags and
  1285.        the other conditions can all be used for the display of conditional
  1286.        text.  The `~jc' flag can also be used for conditional text, and works
  1287.        in the reverse sense to `~hc', only displaying the text if the
  1288.        condition is FALSE.
  1289.  
  1290.        The local flags, and the global flags, can be used for expansion
  1291.        references in the text.  An expansion reference can be set up as the
  1292.        following example:-
  1293.  
  1294.          ~APress to expand / remove additional information~PZL3~E
  1295.          ~h3This is additional information
  1296.          ~h3which is displayed when the above
  1297.          ~h3reference is selected.
  1298.          ~j3This is an alternative piece of text otherwise shown
  1299.  
  1300.        Note that the conditional text lines would be displayed after the
  1301.        reference normally, but this is not strictly necessary and they may
  1302.        appear anywhere in the frame display, including pages not currently on
  1303.        display.
  1304.  
  1305.        The conditional text concept may also be used for expertise levels in
  1306.        help systems, by use of the global application conditions (A to Z).
  1307.        The application flag can be set at any point, and will then influence
  1308.        all text conditional on it.  Thus, text for the beginner may be shown
  1309.        if the application flag B is set, as follows:-
  1310.  
  1311.          ~hBThe space bar is the long key at the front
  1312.          ~hBof the keyboard used for entering spaces.
  1313.  
  1314.  
  1315.  
  1316.  
  1317.                                        - 48 -
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.        HyperShell Users Guide                        The HyperShell language
  1325.  
  1326.  
  1327.        Note that ~Z flags are required after conditional text if the
  1328.        conditional text flag is not at the start of the line, and is
  1329.        sandwiched between unconditional text.
  1330.  
  1331.          ~AToggle flag~PZL7~E ~h7Flag 7 On~Z ~j7Local flag 7 Off~Z
  1332.  
  1333.        The frame is refreshed after a `ZL' action, so that any conditional
  1334.        text is shown / hidden.  The refresh may be suppressed by adding an
  1335.        extra character to the action:-
  1336.  
  1337.          ZL4#
  1338.  
  1339.        Conditional actions and branches
  1340.  
  1341.        We have seen the conditional jump action `j' used in examples.  We
  1342.        have also seen the conditional action `a' used.  The reverse
  1343.        conditional action code `z' is similar to `a' only works in reverse.
  1344.        All these can be used with any of the condition codes.
  1345.  
  1346.          jzFILE ERROR    jumps to label FILE ERROR if file error
  1347.  
  1348.          Vn@MNames
  1349.          zbq          Quits script if no selection made from menu
  1350.  
  1351.        Conditional menu options
  1352.  
  1353.        A third place we can use conditions is in menus.  If we only want to
  1354.        display options under certain conditions, we can use the following
  1355.        notation in a menu:-
  1356.  
  1357.          ?coption
  1358.        or
  1359.          \coption
  1360.  
  1361.        Where `c' is the condition code, and option is the menu option with or
  1362.        without a separate action.  The `?' code indicates that the option
  1363.        should be included only if the condition is TRUE.  The `\' option
  1364.        indicates that the option should only be included if the condition is
  1365.        FALSE.
  1366.  
  1367.          +-----------------------------+
  1368.          |.MENU Information            |
  1369.          |?BHelp |NBeginners help      |
  1370.          |\BHelp |NExperts help        |
  1371.          |.                            |
  1372.          +-----------------------------+
  1373.  
  1374.        This menu displays a different help note depending on whether the
  1375.        application flag B is set or not.
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.                                        - 49 -
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.        The HyperShell language                       HyperShell Users Guide
  1391.  
  1392.  
  1393.        4.2.14 Scripts
  1394.  
  1395.        The HyperShell program is an interpreter, similar in many ways to a
  1396.        high level language interpreter such as BASIC. Because it was designed
  1397.        for the presentation of information, it does not contain conventional
  1398.        language statements, floating point arithmetic, arrays or structured
  1399.        data items.  Nevertheless, a lot of conventional programming
  1400.        constructs can be achieved using the SCRIPT facility, and the large
  1401.        set of actions and action modifiers available.
  1402.  
  1403.        First, a word about how scripts are defined and called.  Defining a
  1404.        script is similar to defining a note or a menu, and scripts can also
  1405.        be global or local to frames.  A script starts with the line:-
  1406.  
  1407.          .SCRIPT script name
  1408.  
  1409.        Script names can be like note and menu names. As the script name will
  1410.        not be seen by the user (unless it is a direct script reference in the
  1411.        text), it can have any suitable name.  A script might look like the
  1412.        following:-
  1413.  
  1414.          +-------------------------------------+
  1415.          |.SCRIPT display notes                |
  1416.          |-- Display notes about pets          |
  1417.          |Ncat                                 |
  1418.          |Ndog;NHamster                        |
  1419.          |-- Display Help menu                 |
  1420.          |MHelp                                |
  1421.          |-- Display pets frame                |
  1422.          |FPets                                |
  1423.          +-------------------------------------+
  1424.  
  1425.        A script simply consists of a sequence of actions or multiple actions,
  1426.        possibly interspersed with comments.  A comment is a line starting
  1427.        with the hyphen character (ie. minus sign `-').  Script lines can be
  1428.        `indented' for clarity using spaces and TABs at the start of the line.
  1429.  
  1430.        A multiple action is a sequence of actions separated by semi-colon
  1431.        characters (ie. `;'). Multiple actions are a convenient way of coding
  1432.        a sequence of actions which may or may not depend on each other. If an
  1433.        action fails, the remaining actions in a multiple action are not
  1434.        performed.
  1435.  
  1436.        The script can be driven from a script reference in the text, in the
  1437.        following form:-
  1438.  
  1439.          ~Sscript name~E   or   ~sscript name~E (for a local script)
  1440.  
  1441.        The script can also be invoked by an action of the form:-
  1442.  
  1443.          Sscript name
  1444.  
  1445.        The processing of a script is terminated when:-
  1446.  
  1447.  
  1448.  
  1449.                                        - 50 -
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.        HyperShell Users Guide                        The HyperShell language
  1457.  
  1458.  
  1459.        1.  It reaches the end, or a `q' action
  1460.        2.  A further script is called
  1461.        3.  ESC is pressed to cancel a menu or other display
  1462.        4.  A new frame is displayed (unless using the `f' action)
  1463.  
  1464.        Another kind of script is the script file.  This is an external file
  1465.        which is interpreted as a script.  It is called as follows:-
  1466.  
  1467.          cscriptfile
  1468.  
  1469.        where `scriptfile' specifies the name of the script and may have its
  1470.        extension omitted, in which case .HSF is assumed.
  1471.  
  1472.        4.2.15 Control structures
  1473.  
  1474.        The script facilities in HyperShell permit a form of programming to be
  1475.        achieved.  A simple sequence of actions may be performed in a script,
  1476.        and control flow actions are provided to allow loops, conditional
  1477.        branching and computed branching to occur.  A trace facility is
  1478.        provided to assist with the debugging of scripts.  HyperShell does not
  1479.        yet have any specific loop control instructions, but loops are easy to
  1480.        program using the Jump action.  Thus, a BASIC loop of the form:-
  1481.  
  1482.          FOR A = 1 TO 20
  1483.          . . .
  1484.          NEXT A
  1485.  
  1486.        is handled as follows:-
  1487.  
  1488.          +-----------------------------+
  1489.          |VA1                          | Set A to 1
  1490.          |Lloop                        | Label loop
  1491.          | . . .                       | instructions
  1492.          |VA=A+1;vA21;jlloop           | Increment and loop
  1493.          +-----------------------------+
  1494.  
  1495.        The `L' action must appear as the first action on a line.
  1496.        The `j' action is a conditional jump action, which branches to the
  1497.        named label if the condition ('l' in this case) is true.
  1498.  
  1499.        As the expression evaluation modifier sets the condition code, a
  1500.        decreasing loop is easier to use when the variable is not used in the
  1501.        loop body.
  1502.  
  1503.          +-----------------------------+
  1504.          |VA20                         | Set top of loop
  1505.          |Lloop                        | Label
  1506.          | . . .                       | instructions
  1507.          |VA=A-1;jnloop                | Decrement and loop
  1508.          +-----------------------------+
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.                                        - 51 -
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.        The HyperShell language                       HyperShell Users Guide
  1523.  
  1524.  
  1525.        IMPORTANT: There is an unexpected side effect of HyperShell compound
  1526.        statements.  If further actions follow a Jump instruction in a
  1527.        compound statement, the further actions are executed regardless of
  1528.        whether the jump is actioned.
  1529.  
  1530.        Computed GOTO statements in BASIC of the form:-
  1531.  
  1532.          ON a GOTO 110,120,130,140
  1533.  
  1534.        can be coded in HyperShell with a simple Jump specifying the value of
  1535.        a variable.
  1536.  
  1537.          J$a
  1538.  
  1539.        The variable, `a' in this case, need not contain a numeric value, as a
  1540.        label can be any alphabetic string.  E.g. to branch depending on the
  1541.        value returned from a confirmation prompt:-
  1542.  
  1543.          +---------------------------+
  1544.          |J$c                        | Jump to value of c
  1545.          |. . .                      |
  1546.          |LYes                       | If c is `Yes'
  1547.          |... actions if Yes ...     |
  1548.          |Jend                       |
  1549.          |LNo                        | If c is `No'
  1550.          |... actions if No ...      |
  1551.          |Lend                       | Common end point
  1552.          +---------------------------+
  1553.  
  1554.        Of course, the Jump action can have its parameter supplied from one of
  1555.        a number of action modifiers, so a number of potential labels could be
  1556.        presented as a menu:-
  1557.  
  1558.          J@Mchoices
  1559.  
  1560.        NOTE:  It is not possible to supply the name of a label in a variable
  1561.        token in an `L' action.
  1562.  
  1563.        4.2.16 Subroutines
  1564.  
  1565.        Subroutines are sequences of code which are common to more than one
  1566.        piece of processing, and therefore should not be repeated.  To place
  1567.        the common processing in one section of code usable from different
  1568.        areas offers a number of advantages.  Firstly the code only has to be
  1569.        written once.  Secondly the code does not have to physically exist
  1570.        more than once, saving space.  Thirdly, there is only one bit of code
  1571.        to maintain (ie. to get the bugs out of and to change if circumstances
  1572.        change).
  1573.  
  1574.        BASIC uses the GOSUB verb to branch to a `subroutine' line number, and
  1575.        a RETURN verb to return to the line after the GOSUB.
  1576.  
  1577.        HyperShell has a similar mechanism.  A jump to subroutine action is
  1578.        provided, which is coded in a script as in the following example:-
  1579.  
  1580.  
  1581.                                        - 52 -
  1582.  
  1583.  
  1584.  
  1585.  
  1586.  
  1587.  
  1588.        HyperShell Users Guide                        The HyperShell language
  1589.  
  1590.  
  1591.  
  1592.          +-------------------------------+
  1593.          | . . .                         |
  1594.          |ZJsubrtn                       | Jump to subroutine--+
  1595.          | . . .                         | come back to here   | <+
  1596.          | . . .                         |                     |  |
  1597.          |q                              | don't fall into it! |  |
  1598.          |Lsubrtn                        | Subroutine       <--+  |
  1599.          | . . .                         |                        |
  1600.          |ZE                             | return from subroutine-+
  1601.          +-------------------------------+
  1602.  
  1603.        The `ZJ' action causes a branch in a script to the named label.  The
  1604.        `ZE' action subsequently causes a return to the line after the `ZJ'
  1605.        action.
  1606.  
  1607.        Whilst this structure is useable in a large script, you may have some
  1608.        processing which you wish to use in a number of scripts.  The script
  1609.        concatenation operator can be used to add a script containing the
  1610.        subroutine (or subroutines) to the end.
  1611.  
  1612.          +----------------------------------+
  1613.          |.SCRIPT main script               |
  1614.          | . . .                            |
  1615.          |ZJsubrtn1                         |
  1616.          | . . .                            |
  1617.          |ZJsubrtn2                         |
  1618.          | . . .                            |
  1619.          |q                                 |
  1620.          |-- Append subroutine script       |
  1621.          |+Subroutines                      |
  1622.          +----------------------------------+
  1623.  
  1624.          +----------------------------------+
  1625.          |.SCRIPT Subroutines               |
  1626.          |q                                 | to stop accidents
  1627.          |-- First subroutine               |
  1628.          |Lsubrtn1                          |
  1629.          | . . .                            |
  1630.          |ZE                                |
  1631.          |-- Second subroutine              |
  1632.          |Lsubrtn2                          |
  1633.          | . . .                            |
  1634.          |ZE                                |
  1635.          +----------------------------------+
  1636.  
  1637.        The subroutines script can then be added to a number of scripts.  The
  1638.        total number of lines, excluding comment lines, in a script plus
  1639.        concatenated scripts is 200.
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.                                        - 53 -
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.        The HyperShell language                       HyperShell Users Guide
  1655.  
  1656.  
  1657.        4.2.17 Parameters on scripts and notes
  1658.  
  1659.        Normal programming languages provide procedures and functions which
  1660.        can accept parameters (or `arguments').  HyperShell allows parameters
  1661.        to be passed to a script in the following fashion.  If a script is
  1662.        called as follows:-
  1663.  
  1664.          Sscript name(param1,param2,param3)
  1665.  
  1666.        then the total string within parentheses is assigned to system
  1667.        variable `\'. This might not at first seem all that useful, but the
  1668.        variable split action `e' can be used to split the parameter into a
  1669.        number of variables at the start of the script:-
  1670.  
  1671.          +--------------------------------+
  1672.          |.SCRIPT Add three numbers       |
  1673.          |-- split into a,b and c         |
  1674.          |e\,abc                          |
  1675.          |-- display sum on bottom line   |
  1676.          |p=a+b+c                         |
  1677.          |-- return                       |
  1678.          |q                               |
  1679.          +--------------------------------+
  1680.  
  1681.        Also, a variable name can be passed in to receive a result (or a few
  1682.        names can be passed in to receive a number of results:-
  1683.  
  1684.          +-------------------------------------------+
  1685.          |.SCRIPT Sum and Difference                 |
  1686.          |-- split into a,b,c and d                  |
  1687.          |e\,abcd                                    |
  1688.          |-- put sum in variable named by c          |
  1689.          |V$c=a+b                                    |
  1690.          |-- put difference into variable named by d |
  1691.          |V$d=a-b                                    |
  1692.          |-- return                                  |
  1693.          |q                                          |
  1694.          +-------------------------------------------+
  1695.  
  1696.        A parameter can also be passed to a note in a similar fashion:-
  1697.  
  1698.          NNote name(Parameter)
  1699.  
  1700.        So if we have a note defined as:-
  1701.  
  1702.          +-----------------------------------------+
  1703.          |.NOTE Confirm                            |
  1704.          |   $\ - Please confirm                   |
  1705.          |                                         |
  1706.          | ~A YES ~PY~Ky~E     ~A  NO  ~PN~Kn~E    |
  1707.          |                                         |
  1708.          +-----------------------------------------+
  1709.  
  1710.  
  1711.  
  1712.  
  1713.                                        - 54 -
  1714.  
  1715.  
  1716.  
  1717.  
  1718.  
  1719.  
  1720.        HyperShell Users Guide                        The HyperShell language
  1721.  
  1722.  
  1723.        We can use this to ask for confirmation on anything, for instance in a
  1724.        script:-
  1725.  
  1726.          +--------------------------------------+
  1727.          | . . .                                |
  1728.          |-- Ask for confirmation               |
  1729.          |Vc@NConfirm(Delete File)              |
  1730.          |-- If yes not selected, quit script   |
  1731.          |vcY;anq                               |
  1732.          |-- Delete the file                    |
  1733.          |d DEL DATA.DAT                        |
  1734.          | . . .                                |
  1735.          +--------------------------------------+
  1736.  
  1737.        The `@N' dynamic menu is another use for a note.  The note is
  1738.        displayed, and if any reference is selected in the note, its value is
  1739.        returned.
  1740.  
  1741.        4.2.18 Access to the environment
  1742.  
  1743.        MSDOS provides a set of strings called `environment variables'.  These
  1744.        are set using the MSDOS `SET' command, and include such things as the
  1745.        PATH variable, which specifies where programs can be found.
  1746.  
  1747.        HyperShell can access the environment variables using an action
  1748.        modifier as follows:-
  1749.  
  1750.          Vp%PATH
  1751.  
  1752.        This sets variable `p' to the value of the PATH environment variable.
  1753.  
  1754.        Environment variables can therefore be used to hold information which
  1755.        you can access from within HyperShell.
  1756.  
  1757.        HyperShell can also set environment variables, but as the environment
  1758.        which HyperShell accesses is just a copy of the MSDOS environment,
  1759.        variables are not available after HyperShell exits.  However, if
  1760.        HyperShell runs other programs, information can be passed to these
  1761.        through the environment, as this is copied for the programs run by
  1762.        HyperShell.  The action `ZS' is used for this purpose:-
  1763.  
  1764.        ZSNAME=FRED
  1765.  
  1766.        NOTE: Environment variable values must adhere to the rules set by
  1767.        MSDOS.
  1768.  
  1769.        4.2.19 Simple interaction
  1770.  
  1771.        The BASIC interaction commands are very useful for communicating with
  1772.        the user.  HyperShell has some equivalents to the simple interaction
  1773.        commands as follows:-
  1774.  
  1775.          Vn?Enter your name   (BASIC INPUT "Enter your name";n$)
  1776.  
  1777.  
  1778.  
  1779.                                        - 55 -
  1780.  
  1781.  
  1782.  
  1783.  
  1784.  
  1785.  
  1786.        The HyperShell language                       HyperShell Users Guide
  1787.  
  1788.  
  1789.          pHello   (BASIC PRINT "Hello")
  1790.  
  1791.          pYour name is $n    (BASIC PRINT "Your name is ";n$)
  1792.  
  1793.        Do not confuse the use of the dollars in the last example.  BASIC uses
  1794.        dollar signs for an altogether different purpose to HyperShell.
  1795.  
  1796.        HyperShell provides some extensions to this interaction.  If one of a
  1797.        number of fixed strings is to be entered, the set of strings can be
  1798.        presented as a menu.  If a more elaborate prompting method is
  1799.        required, a note containing and input field can be popped up as a
  1800.        dialogue box.  The menu or note are then used to supply the value to
  1801.        the variable:-
  1802.  
  1803.          Vt@MCar type
  1804.  
  1805.          Vc@NConfirm
  1806.  
  1807.        Where a single character input is required, the Key function can be
  1808.        used.  This is coded as e.g.
  1809.  
  1810.          Vx&KPress a key
  1811.  
  1812.        And is the equivalent of the BASIC:-
  1813.  
  1814.          30 PRINT "Press a key"
  1815.          40 X$ = ""
  1816.          50 X$ = INKEY$(): IF X$ = "" GOTO 50
  1817.  
  1818.        Prompted input can provide a value for editing, rather than demanding
  1819.        a complete new input each time.  This is specified by appending a `/'
  1820.        character and the default value.  This is usually a default value or
  1821.        the previous value of a variable:-
  1822.  
  1823.          Vd?Enter Transaction Date/$4
  1824.  
  1825.        Note that variable 4 will be expanded before being presented for
  1826.        editing.
  1827.  
  1828.          Vn?Enter you name/$n
  1829.  
  1830.        The previous value of variable `n' will be offered for editing.
  1831.  
  1832.        The `P' action pops up a flashing `message' at the current mouse
  1833.        cursor position, and awaits a key or mouse button depression before
  1834.        `popping down'.
  1835.        eg.
  1836.          PHello there!
  1837.  
  1838.        If a null string is passed as a parameter, an asterisk will flash in
  1839.        the bottom right hand corner of the screen. This can be used as a
  1840.        pause to await a key depression from the user before continuing with a
  1841.        series of actions.
  1842.  
  1843.  
  1844.  
  1845.                                        - 56 -
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.        HyperShell Users Guide                        The HyperShell language
  1853.  
  1854.  
  1855.        4.2.20 String Functions
  1856.  
  1857.        A number of string functions are available as `action modifiers'.
  1858.        Strictly, all action modifiers are functions of some sort, but the
  1859.        string functions are classified as `functions' to separate them from
  1860.        the dynamic menus and other string providers.  The string functions
  1861.        provide a set of facilities analogous to the BASIC functions, although
  1862.        even those returning a numeric result are classified as string
  1863.        functions in this case, both because they operate on strings, and
  1864.        because they return the result as an ASCII string regardless.  The
  1865.        functions take the form:-
  1866.  
  1867.          &FPstring
  1868.  
  1869.        Where `F' is the function code, `P' is an optional parameter and
  1870.        `string' is the string to apply the function against.  Some common
  1871.        string functions with an equivalent BASIC function are as follows:-
  1872.  
  1873.          &L - Length of argument (BASIC LEN)
  1874.          &A - ASCII value of first char of argument (BASIC ASC)
  1875.          &C - character with ASCII value argument (BASIC CHR$)
  1876.          &Sn - substring starting at nth character (BASIC MID$)
  1877.          &Ic - index of character `c', or 0 if none (BASIC INSTR)
  1878.          &K - single character input (Basic INKEY$)
  1879.  
  1880.        Also similar functions are provided as follows:-
  1881.  
  1882.          &Nn - nth character in argument
  1883.          &Uc - substring up to, but not including character `c'
  1884.          &Fc - substring from character `c' inclusive
  1885.  
  1886.        A number of other functions exist and are documented in the reference
  1887.        guide.
  1888.  
  1889.        4.2.21 Scale number
  1890.  
  1891.        HyperShell deals in integers, or `whole' numbers.  This means that
  1892.        calculations for money, for example, have to be carried out in smaller
  1893.        units (pence in the case of money), and the result `scaled' for
  1894.        display.
  1895.  
  1896.        The `&B' function is used for this purpose.  It takes the next
  1897.        character as the number of decimal places to display. eg. to display
  1898.        the value of variable `m' with two decimal places:-
  1899.  
  1900.          &B2$m
  1901.  
  1902.        So:-
  1903.  
  1904.          &B212345       - returns 123.45
  1905.  
  1906.          &B312          - returns 0.012
  1907.  
  1908.  
  1909.  
  1910.  
  1911.                                        - 57 -
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.        The HyperShell language                       HyperShell Users Guide
  1919.  
  1920.  
  1921.        4.2.22 File input / output
  1922.  
  1923.        Most languages provide some form of file input and output. HyperShell
  1924.        provides a fairly straightforward means of reading or writing to a
  1925.        file.  It is not intended as a fully fledged language, so only permits
  1926.        one input and one output file at a time.  It is possible to have one
  1927.        file open for input and to keep this open whilst another file is
  1928.        opened for input, read and closed, however.
  1929.  
  1930.        To open a file for reading or writing, the action:-
  1931.  
  1932.          rfilename / wfilename
  1933.  
  1934.        is issued (r for read, w for write).  To read a record, two mechanisms
  1935.        are provided.  The formatted read allows a set of variables to be
  1936.        loaded from `fields' in a text record.  The `R' action is used for
  1937.        this:-
  1938.  
  1939.          R:abcdef
  1940.  
  1941.        Reads the next input record and splits it into variables a,b,c,d,e and
  1942.        f on a separator `:'.
  1943.  
  1944.        The other means of reading an input record is provided by the iterator
  1945.        action modifier - `!'. This can be used in a number of ways.  The
  1946.        simplest construct is `!' by itself, which returns the next input
  1947.        record.  Other constructs provide lookup capabilities. The form:-
  1948.  
  1949.          !Fkey
  1950.  
  1951.        reads the next record starting with the string `key'.  If it is
  1952.        necessary to read the first record in the file starting with the
  1953.        `key', the format:-
  1954.  
  1955.          !Lkey
  1956.  
  1957.        is used instead.  Thus this method can be used to provide a lookup
  1958.        facility.  This lookup is performed sequentially, however, so cannot
  1959.        be practically used if the file concerned is huge.  A special format
  1960.        is provided which can search very large file provided they are sorted
  1961.        into ascending order:-
  1962.  
  1963.          !Bkey
  1964.  
  1965.        This does a very fast search on the file using a `binary chop' search
  1966.        algorithm.
  1967.  
  1968.        File output is done using the `W' action.  This simply takes its
  1969.        argument as the record to be written.  The record can be formed from
  1970.        any of the standard action modifiers, or from variable tokens:-
  1971.  
  1972.          W$a:$b:$c:$d:$e:$f
  1973.  
  1974.  
  1975.  
  1976.  
  1977.                                        - 58 -
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.        HyperShell Users Guide                        The HyperShell language
  1985.  
  1986.  
  1987.        which would write a record made up of the variables a to f separated
  1988.        by `:' characters.
  1989.  
  1990.        4.2.23 Printed output
  1991.  
  1992.        It is useful to be able to output information to the printer.  The `o'
  1993.        action is provided for this purpose.  It does, however, provide a
  1994.        `device independent' route for output information, controlled by
  1995.        option 5.  Option 5 should be set to 1 for output to go to the
  1996.        printer.
  1997.  
  1998.          O51
  1999.  
  2000.        The `o' action works in a similar fashion to the `W' action:-
  2001.  
  2002.          oThis line goes to the printer
  2003.  
  2004.        The set of values for option 5 are as follows:-
  2005.  
  2006.           Output routes
  2007.          +-------------------------------------------+
  2008.          | O50 | Display output on bottom line       |
  2009.          | O51 | Print output on printer             |
  2010.          | O52 | Direct output to `standard output'  |
  2011.          | O53 | Direct output to AUX device         |
  2012.          | O54 | Write output to current output file |
  2013.          +-------------------------------------------+
  2014.  
  2015.        Having the output controllable in this fashion allows the same set of
  2016.        code to output the same information to one of a number of routes.  For
  2017.        example reports can be directed at a file or straight to the printer.
  2018.  
  2019.        Standard output is the standard output stream used by MSDOS for
  2020.        display on the screen or redirection to one of a number of routes
  2021.        using the `>' or `|' command line options.
  2022.  
  2023.        The current output file is that, if any, opened using a `wfilename'
  2024.        action.
  2025.  
  2026.        4.2.24 Backtracking
  2027.  
  2028.        Wandering through a maze of hypertext information can easily make the
  2029.        user feel `lost in hyperspace'.  HyperShell helps out in a number of
  2030.        ways with enabling the user to get back to where they wanted to be.
  2031.        The backtrack list is maintained (unless the author has prevented
  2032.        this) as the user wanders from frame to frame.  The F3 key is mapped
  2033.        to the simple single step backtrack, and successive depression of this
  2034.        leads the user back to the main track.  The F4 key is mapped to the
  2035.        multiple backtrack list, which enables the user to jump directly back
  2036.        to one of the frames he has visited.
  2037.  
  2038.        The F3 key is mapped to the simple backtrack action:-
  2039.  
  2040.          B
  2041.  
  2042.  
  2043.                                        - 59 -
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.        The HyperShell language                       HyperShell Users Guide
  2051.  
  2052.  
  2053.  
  2054.        The F4 key is mapped to a dynamic menu which returns the backtrack
  2055.        level, and uses this to unwind to that level. The action is
  2056.        therefore:-
  2057.  
  2058.          b@B
  2059.  
  2060.        Another kind of backtrack selection is possible. The `@b' dynamic menu
  2061.        does not return a backtrack level, but instead returns a frame display
  2062.        action, as in the contents and search lists.  This can be used in the
  2063.        following form:-
  2064.  
  2065.          A@b
  2066.  
  2067.        which has the effect of `revisiting' the frame, without unwinding the
  2068.        backtrack list.
  2069.  
  2070.        4.2.25 Expression evaluation
  2071.  
  2072.        As explained above, we can code simple expressions to work with
  2073.        numeric variables.  So, for instance, we code the following to add
  2074.        variables b and c giving variable a:-
  2075.  
  2076.          Va=b+c
  2077.  
  2078.        The expression evaluation operator is capable of much more than this,
  2079.        and can handle boolean and bit arithmetic operations as well as other
  2080.        complex structures. eg.
  2081.  
  2082.           Bit operations
  2083.          +-----------------------------------------------+
  2084.          |expr!expr | arithmetic or   |  2!3  | returns 3|
  2085.          |expr&expr | arithmetic and  |  2&3  | returns 2|
  2086.          |expr^expr | exclusive or    |  2^3  | returns 1|
  2087.          |@expr     | 1's complement  |       |          |
  2088.          +-----------------------------------------------+
  2089.  
  2090.           Boolean operations
  2091.          +-----------------------------------------------------+
  2092.          |expr>expr | greater  |These return | 2>3 | returns 0 |
  2093.          |expr<expr | less     | 0 if false  | 2<3 | returns 1 |
  2094.          |expr=expr | equal    | 1 if true   | 2=3 | returns 0 |
  2095.          |~expr     | not expr |             |     |           |
  2096.          +-----------------------------------------------------+
  2097.          also:-
  2098.           #c        condition code truth   #s returns 1 if error
  2099.           "vxxxx"c  combined variable comparison and condition
  2100.           truth   "nfred"e!"njim"e returns 1 if n = fred or jim
  2101.  
  2102.        Also the following triadic conditional operator is provided:-
  2103.  
  2104.          expr?true expr:false expr
  2105.  
  2106.        eg.
  2107.  
  2108.  
  2109.                                        - 60 -
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.        HyperShell Users Guide                        The HyperShell language
  2117.  
  2118.  
  2119.  
  2120.          a<3?45:78
  2121.  
  2122.        This returns 45 if variable a less than 3 else it returns 78.
  2123.  
  2124.        The `truth' can be tested using the `n' condition code which is set to
  2125.        reflect a non-zero result:-
  2126.  
  2127.          Y=(a<3)!(a>23);jnOUTSIDE RANGE
  2128.  
  2129.        The `ZI' action (pronounced `IF') is especially designed for use with
  2130.        boolean expressions and compound conditions.  This is used at the
  2131.        start of a multiple action, where the rest of the multiple action is
  2132.        executed if the condition is true.
  2133.  
  2134.          ZIx>100;Px is over one hundred
  2135.  
  2136.          ZI"ntaylor"c;Phis name contains `taylor'
  2137.  
  2138.        4.2.26 Mouse cursor positioning
  2139.  
  2140.        As popup menus, notes and messages are positioned relative to the
  2141.        mouse cursor, it is useful to be able to position the mouse cursor so
  2142.        that the popup appears where you want it.  This is done using the `ZX'
  2143.        and `ZY' actions, which set the column and line position of the mouse
  2144.        cursor. eg. set cursor at column 3 of line 15:-
  2145.  
  2146.          ZX3;ZY15
  2147.  
  2148.        4.2.27 Searching
  2149.  
  2150.        Hypertext documents, whether they be reference manuals or information
  2151.        bases, need a search capability to allow information about a
  2152.        particular topic to be located, if this is not readily available
  2153.        through the normal navigational channels.
  2154.  
  2155.        HyperShell provides a number of different dynamic menus to provide a
  2156.        search capability against the text.  The two basic types are a search
  2157.        against the frame names and titles, and a search against the names,
  2158.        titles and text of frames.  The search menus return a frame reference
  2159.        if one is selected from the menu.
  2160.  
  2161.          A@S?search string
  2162.  
  2163.        prompts for a string and searches for it in the frame names and titles
  2164.        of the current hyperfile.  All matching frames are listed, allowing
  2165.        one to be selected.  If one is selected, the frame display action is
  2166.        returned and the `A' action performs this to display the frame.  You
  2167.        may recognise this as the default action mapped to function key F6.
  2168.  
  2169.        The `@X' menu does a search of the frame text as well.
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.                                        - 61 -
  2176.  
  2177.  
  2178.  
  2179.  
  2180.  
  2181.  
  2182.        The HyperShell language                       HyperShell Users Guide
  2183.  
  2184.  
  2185.        Selecting from the menu of matching frames during the search might be
  2186.        what we wish to do if we spot the frame we were after.  If it is not
  2187.        the frame we were after we might have to run the search again.  One
  2188.        way of avoiding this is to allow the search to complete, then present
  2189.        a list of matching frames.  This is achieved in a two stage process.
  2190.        To do the initial search, we code the following multiple action:-
  2191.  
  2192.          O*65;A@S?Search string
  2193.  
  2194.        This will do the same search as previously, but will not stop to allow
  2195.        a frame to be selected.  In fact, as the dynamic menu cannot return
  2196.        anything, the `A' action code is redundant.
  2197.  
  2198.        Well. How do we display the list of matching frames?  This is done
  2199.        using a variant of the contents list.  The contents list, mapped by
  2200.        default to F2, provides a listing of frames in the hyperfile.  It is
  2201.        another dynamic menu returning the selected frame reference, and a
  2202.        contents list usually takes the form:-
  2203.  
  2204.          A@C
  2205.  
  2206.        This contents list displays all frames, but it flags those which
  2207.        matched the last search with a small arrow to the left of the frame
  2208.        name.  We might not want to look through pages of frames for flags,
  2209.        however.  To display a contents list of just those frames which
  2210.        matched the search, the following variant is used:-
  2211.  
  2212.          A@C1
  2213.  
  2214.        These contents lists can be repeated to display the matching frames
  2215.        for selection, whilst the frames are selected one at a time.
  2216.  
  2217.        Another way we can go through the matching frames is to select the
  2218.        first matching frame initially.  To step to the next matching frame,
  2219.        the action `F+1' can then be used.
  2220.  
  2221.        Of course, we can't expect the user to type in all these actions
  2222.        himself.  We could provide a menu which offered all these stages:-
  2223.  
  2224.          +-------------------------------------------+
  2225.          |.MENU Search Control                       |
  2226.          |Search for string   |O*65;A@SSearch string |
  2227.          |List matching frames|A@C1                  |
  2228.          |Next matching frame |F+1                   |
  2229.          +-------------------------------------------+
  2230.  
  2231.        Then we could map this menu to the F6 key as follows:-
  2232.  
  2233.          KF6MSearch Control
  2234.  
  2235.        This uses the key mapping action described previously to map the
  2236.        Search Control menu to the F6 key.
  2237.  
  2238.  
  2239.  
  2240.  
  2241.                                        - 62 -
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.        HyperShell Users Guide                        The HyperShell language
  2249.  
  2250.  
  2251.        4.2.28 The Notepad
  2252.  
  2253.        The notepad is a list of reference strings used as `bookmarks'.  The
  2254.        usual way of adding references to the notepad is the INS key, with the
  2255.        DEL key removing them again.  The notepad may also have data added and
  2256.        removed by the `H' and `h' actions.  The items on the notepad are
  2257.        normally assumed to be action specifications, although it is possible
  2258.        to store other data on the list for selection for other purposes.
  2259.  
  2260.        The INS key, and `H' action, by default requests a comment string
  2261.        which is associated with the reference when it is listed.  This can be
  2262.        suppressed using the option flag setting:-
  2263.  
  2264.          O*80
  2265.  
  2266.        The notepad display dynamic menu `@R' displays a paged list of the
  2267.        contents of the notepad.  It returns the action associated with the
  2268.        selected notepad item, and is usually used with the `A' action, as in
  2269.        the F5 default mapping:-
  2270.  
  2271.        A@R
  2272.  
  2273.        It is also possible to read the notepad like a file.  The `!R'
  2274.        iterator is used to return successive items from the notepad.  The
  2275.        `!C' iterator returns the associated comment.  The `!R' iterator can
  2276.        also have a key appended, which causes the references to be scanned
  2277.        for one starting with the key string. For example, to return the next
  2278.        note reference:-
  2279.  
  2280.          !RN
  2281.  
  2282.        Any search or step is taken from after the last reference obtained.
  2283.        The scan pointer is reset whenever a reference is added or removed
  2284.        from the list, and can be rewound with a dummy `remove' action:-
  2285.  
  2286.          h
  2287.  
  2288.        The EOF status is set when the end of the references is reached.
  2289.  
  2290.        4.3 Application structures
  2291.  
  2292.        This section describes the use of HyperShell in various application
  2293.        areas.  The structures described may relate to specific areas, or may
  2294.        be of general use.  It is worthwhile becoming familiar with the
  2295.        capabilities whatever application you will be developing.
  2296.  
  2297.  
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.                                        - 63 -
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.        The HyperShell language                       HyperShell Users Guide
  2315.  
  2316.  
  2317.        4.3.1 Frames as menus
  2318.  
  2319.        The term `menu' is used somewhat freely in the computing sector to
  2320.        mean petty well any representation of a choice of selections. The
  2321.        original menu systems provided a screen display with a set of numbered
  2322.        options. Pressing the number key selected the option and caused the
  2323.        display of a further menu in a hierarchy, or in the running of a
  2324.        program function.  HyperShell menus are of the more recent `popup'
  2325.        variety, but HyperShell frames are ideally suited for use as this
  2326.        other form of menu.  Thus HyperShell can also be used as a versatile
  2327.        menu system, with capabilities well beyond those of other menu systems
  2328.        on the market, such as displaying graphic images, incorporating
  2329.        application related help, and providing form-fill capabilities for
  2330.        inputting program parameters.
  2331.  
  2332.        A simple menu system can be built using a frame for each menu.  The
  2333.        higher levels of menu consist of frames containing choices leading to
  2334.        frame references to the lower levels.  At the bottom level, selection
  2335.        of a reference will cause the invocation of a program command line.
  2336.  
  2337.        A simple one frame menu can be used to drive a small number of
  2338.        programs. entering an empty HEADER item and the text from the FRAME as
  2339.        below:-
  2340.  
  2341.          +----------------------------------------+
  2342.          |.HEADER                                 | Null header
  2343.          |.SCRIPT SETUP                           |
  2344.          |O62                                     | Enable swapping
  2345.          |.FRAME menu1                            |
  2346.          |                                        |
  2347.          |   --- My Menu ---                      |
  2348.          |                                        |
  2349.          |~A1.  Accounts~PDaccounts~K1~E          | DOS program
  2350.          |                                        |
  2351.          |~A2.  Invoices~PDinvoices~K2~E          | DOS program
  2352.          |                                        |
  2353.          |~A3.  Payroll~PDpayroll~K3~E            | DOS program
  2354.          |                                        |
  2355.          |~A4.  Spreadsheet~PE123~K4~E            | Chained program
  2356.          |                                        |
  2357.          |~A5.  Exit~PQ~K5~E                      |
  2358.          |.                                       |
  2359.          +----------------------------------------+
  2360.  
  2361.        This menu allows the options to be selected as normal, or by use of
  2362.        the numeric keys 1 to 5.  Note that the spreadsheet option causes the
  2363.        program to be chained rather than executed as a sub-process, to allow
  2364.        the spreadsheet to have all the memory to itself.  The null header is
  2365.        used in hyperfiles to suppress the default header display.
  2366.  
  2367.        Of course, a multiple menu system can be constructed using a frame for
  2368.        each menu, with selections simple moving to other frames, or invoking
  2369.        programs at the lowest point.
  2370.  
  2371.  
  2372.  
  2373.                                        - 64 -
  2374.  
  2375.  
  2376.  
  2377.  
  2378.  
  2379.  
  2380.        HyperShell Users Guide                        The HyperShell language
  2381.  
  2382.  
  2383.        The E action can be used, and the menu hyperfile can be re-entered at
  2384.        the same point, by using the -r flag to save a restart file, and by
  2385.        coding the HyperShell invocation in a loop in a batch file:-
  2386.  
  2387.          +---------------------------+
  2388.          |:LOOP                      |
  2389.          |hs -r menu                 |
  2390.          |if errorlevel 1 goto QUIT  |
  2391.          |goto LOOP                  |
  2392.          |:QUIT                      |
  2393.          +---------------------------+
  2394.  
  2395.        The menu hyperfile can then quit by using the `Q1' action string.
  2396.  
  2397.        4.3.2 Program execution
  2398.  
  2399.        Actions are provided to allow other software to be run from a menu
  2400.        application in a number of ways. The DOS command action is available
  2401.        for the majority of tasks, and the chain execution action is available
  2402.        if HyperShell cannot remain resident with heavyweight software or with
  2403.        software requiring lots of data storage.
  2404.  
  2405.        The DOS command action runs a program via the DOS command processor
  2406.        (COMMAND.COM), so can run batch files and built-in commands and can
  2407.        have file indirection parameters added. This action takes the form:-
  2408.  
  2409.          Dprogram parameter parameter parameter . . .
  2410.  
  2411.        The option 6 setting is only applicable to the HS.EXE program, and
  2412.        causes the program to be swapped to disk when it runs another program
  2413.        using the DOS command action. It leaves only 1.5k resident in memory
  2414.        when this happens, rather than the 128k it would otherwise occupy.
  2415.  
  2416.           DOS command action             With swapping
  2417.          +-------------------------+   +------------------------+
  2418.          |    APPLICATION          |   |                        |
  2419.          |      PROGRAM            |   |   APPLICATION          |
  2420.          |                         |   |     PROGRAM            |
  2421.          |-------------------------|   |                        |
  2422.          |    COMMAND.COM          |   |                        |
  2423.          |-------------------------|   |------------------------|
  2424.          |                         |   |  COMMAND.COM           |
  2425.          |    HYPERSHELL (128k)    |   |------------------------|
  2426.          |                         |   |  HYPERSHELL (1.5k)     |
  2427.          +-------------------------+   +------------------------+
  2428.  
  2429.        The chain execution action allows a program to completely overwrite
  2430.        HyperShell in memory, and is specified as follows:-
  2431.  
  2432.          Eprogram parameter parameter . . .
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.                                        - 65 -
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.        The HyperShell language                       HyperShell Users Guide
  2447.  
  2448.  
  2449.        The subprogram execution action is a special purpose variant of the
  2450.        DOS command action, where the program is executed directly and the
  2451.        command processor is not used. This is faster, and provides access to
  2452.        the exit code of the program which is invoked. This action takes the
  2453.        form:-
  2454.  
  2455.          Xprogram parameter parameter . . .
  2456.  
  2457.        When HyperShell is invoked from other programs or batch files, it can
  2458.        set an exit status which may be used by the other program. This is
  2459.        done simply by appending the numeric exit status to the `Q' action
  2460.        used to exit HyperShell.  So, to exit with status 120:-
  2461.  
  2462.          Q120
  2463.  
  2464.        4.3.3 Form Fill
  2465.  
  2466.        HyperShell frames can also be used as data entry forms or database
  2467.        browsing forms.  This is brought about by one powerful type of
  2468.        reference - the input field.  An input field is like any other
  2469.        reference, until you select it.  It then becomes an input area into
  2470.        which you can type a string.  It is generally the case that the input
  2471.        string is used to set a variable, and that the variable is displayed
  2472.        in the field until it is selected.  The width of the field is
  2473.        generally specified in the field specification, as it is this which
  2474.        determines the maximum size of the field.  A typical input field would
  2475.        look like:-
  2476.  
  2477.          ~I$v~W10~PVv%s~E
  2478.  
  2479.        This specifies an input field of length 10, in which the variable `v'
  2480.        is displayed.  After entering a string, it is assigned to the
  2481.        variable.
  2482.  
  2483.        Where a number of fields are supplied in a frame to form a form-fill
  2484.        screen, they can be `chained' to the next input by use of the `I'
  2485.        action.  This causes the next input field to be selected.  e.g.
  2486.  
  2487.          ~I$v~W10~PVv%s;I~E
  2488.  
  2489.        does the same as the above field, and then selects the next input
  2490.        field.  The user sees this as a typical form-fill interaction, and can
  2491.        press ESCAPE to cancel the sequence of inputs.
  2492.  
  2493.        The `immediate reference' flag can be used with form frames to select
  2494.        the first input field, or to execute a script to open files etc.
  2495.        prior to any processing.
  2496.  
  2497.        4.3.4 Data bases
  2498.  
  2499.        The file input and output facilities can be used, along with the form
  2500.        fill, to implement a simple `database'.  These are really `flat files'
  2501.        but everyone else calls these databases, so we will as well!
  2502.  
  2503.  
  2504.  
  2505.                                        - 66 -
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.        HyperShell Users Guide                        The HyperShell language
  2513.  
  2514.  
  2515.        The format of data files described here can be imported and exported
  2516.        by many database systems.  They can also be processed by certain
  2517.        utilities originating on UNIX systems, such as AWK, JOIN, SORT etc.
  2518.  
  2519.        To work through an example we will firstly provide a reference to
  2520.        allow a file to be opened for writing.
  2521.  
  2522.          ~AOpen file for writing~Pwdata.txt+~E
  2523.  
  2524.        The `+' at the end of the filename indicates that the file should be
  2525.        extended if it already exists.  Thus we can add records to an existing
  2526.        file.
  2527.  
  2528.        The last input field on a form could write the data out after input:-
  2529.  
  2530.          ~I$f~W10~PVf%s;W$$a:$$b:$$c:$$d:$$e:$$f~E
  2531.  
  2532.        This would write out a line containing variables `a' to `f' separated
  2533.        by `:' characters.  As an alternative, a separate action reference can
  2534.        be used for writing a record, so that changes can be made to the input
  2535.        fields before writing:-
  2536.  
  2537.          ~AWrite record~PW$$a:$$b:$$c:$$d:$$e:$$f~E
  2538.  
  2539.        Note that the double dollars are needed to stop the variable expansion
  2540.        taking place when the frame is displayed.  To close the file, another
  2541.        action reference of the form:-
  2542.  
  2543.          ~AClose file~Pw~E
  2544.  
  2545.        can be supplied.
  2546.  
  2547.        How about using a form to browse through a database.  To open a file
  2548.        for reading, we have an action:-
  2549.  
  2550.          ~AOpen for reading~Prdata.txt~E
  2551.  
  2552.        If the database consists of text records with fields separated by a
  2553.        special character (like `:' above), we can read a record into a number
  2554.        of variables with one action string:-
  2555.  
  2556.          ~ARead file~PR:abcdef;y~E
  2557.  
  2558.        This reads the next record and refreshes the screen, allowing any
  2559.        variable expansion tokens for the variables input to be expanded.
  2560.        These could be in input field specifications, or elsewhere in the
  2561.        frame text.
  2562.  
  2563.        If we want to perform a lookup in a text file, the `R' action cannot
  2564.        be used.  In this case we could use an input field to input the first
  2565.        variable as a key, and lookup the record.
  2566.  
  2567.          ~I$a~W20~PVr!L%s;er:abcdef;y~E
  2568.  
  2569.  
  2570.  
  2571.                                        - 67 -
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.        The HyperShell language                       HyperShell Users Guide
  2579.  
  2580.  
  2581.        This rather complex action uses the input string as a key to look up a
  2582.        record starting with the key field, reading the record into variable
  2583.        `r'.  It then expands `r' into a,b,c,d,e and f before refreshing the
  2584.        screen to display the values.  Note that a slightly more complicated
  2585.        action is required in practise, as it has to handle the case where the
  2586.        record is not found - the above example would set all variables to a
  2587.        null string (which may be acceptable in some cases).
  2588.  
  2589.        Another thing we can do with our `database' is to produce a simple
  2590.        formatted list.  This is made possible by the `@G' dynamic menu.  This
  2591.        takes the form:-
  2592.  
  2593.          @Gfilename.ext
  2594.  
  2595.        What this returns depends on the format string we set up.
  2596.  
  2597.        To use this, we first have to set up some general strings using the
  2598.        `KG' action.  For our example above, these will be as follows:-
  2599.  
  2600.          KG5:abcdef
  2601.          KG7[%c]  ~A$a~P$a~K%c~E~C20$b $c $d $e $f
  2602.  
  2603.        When the dynamic menu is run, each line in the file is split using the
  2604.        G5 mapping as a string split specification as above.  The format
  2605.        string specified in G7 is then displayed for the line, the variable
  2606.        tokens being expanded to form the tabulated list.  Two `%c' tokens can
  2607.        be inserted in the format line, which are replaced by the lowercase
  2608.        alphabetic letters when the list is produced.  The action reference
  2609.        can be selected, and causes the dynamic menu to return the value of
  2610.        the first field, as loaded into variable `a'.
  2611.  
  2612.        So what is G6 used for, you ask?  The G6 mapping is used to provide a
  2613.        selection expression, which is used to select records to be displayed.
  2614.        By default it is set to `1' indicating that everything should be
  2615.        displayed.  The expression can take the form of the expression used
  2616.        for the `=' action modifier and the `ZI' action.  If the expression
  2617.        evaluates to a non-zero value, the record is displayed, otherwise it
  2618.        is ignored.
  2619.  
  2620.        If, for example, the third field (loaded into variable c) was an AGE
  2621.        field, we could select those people between the ages of 20 and 60
  2622.        using the following mapping:-
  2623.  
  2624.          KG6(c > 19) & (c < 61)
  2625.  
  2626.        Of course, we could allow the user to enter a selection expression.
  2627.        We then have a query language???
  2628.  
  2629.        4.3.5 Directory browsers
  2630.  
  2631.        HyperShell provides a number of directory menus which allow file names
  2632.        to be selected for processing.  The simplest form of directory display
  2633.        is a popup dynamic menu of the form:-
  2634.  
  2635.  
  2636.  
  2637.                                        - 68 -
  2638.  
  2639.  
  2640.  
  2641.  
  2642.  
  2643.  
  2644.        HyperShell Users Guide                        The HyperShell language
  2645.  
  2646.  
  2647.          @Dwildcardspec
  2648.  
  2649.        The `@d' works as for the `@D' menu, only the file extension is
  2650.        included in the menu, and is returned on selection.
  2651.  
  2652.        The `@E' works as for the `@D' menu, only the menu presented only
  2653.        includes subdirectories.
  2654.  
  2655.        The menu return can be used in any action, or dynamic menu, requiring
  2656.        a file specification as a parameter.
  2657.  
  2658.          T@d*.TXT
  2659.  
  2660.        This gives a menu of files with extension .TXT and then displays the
  2661.        file selected.
  2662.  
  2663.          C@E*.*
  2664.  
  2665.        This makes the selected directory current
  2666.  
  2667.        There are also a number of detailed directory listings provided as
  2668.        paged displays.  The extended directory display `@L' presents a paged
  2669.        list showing details of the files matching a wildcard specification.
  2670.        It returns the selected filename, as for the `@D' popup menu.  The
  2671.        filename and the extension are loaded into variables `$<' and `$>',
  2672.        and the extension can be used in a script to select processing which
  2673.        is appropriate for the file type.
  2674.  
  2675.        This is the equivalent of the `object oriented' directory listings of
  2676.        graphical user interfaces such as GEM and Windows.  In fact, a choice
  2677.        of processing via a popup menu can be provided for each file type,
  2678.        unlike the GUIs, which are forced to perform only one action with a
  2679.        file selected in this fashion.
  2680.  
  2681.        Another detailed directory display is available which has actions
  2682.        already added ready for processing.  The `@l' menu provides its own
  2683.        action strings for typing a text file or changing to a directory, and
  2684.        is used with the `A' action.  This is driven by the file extension.
  2685.  
  2686.        4.3.6 Graphic screen display
  2687.  
  2688.        Many hypertext applications can provide sufficient information using
  2689.        textual descriptions, but the use of diagrams and pictures can help
  2690.        enormously in some applications, and are essential in others.
  2691.        HyperShell is normally text based, but supports graphic screen
  2692.        displays with optional selection zones on them.
  2693.  
  2694.        Graphic screens have to be prepared using screen capture, graphic
  2695.        paint packages and graphic conversion programs.  Once a graphic screen
  2696.        in the correct format is available, the zones can be mapped, and the
  2697.        screen integrated with the hyperfile.  Graphic screens are held
  2698.        separately to the hyperfile, and are displayed using the `G' or `g'
  2699.        actions.  These display a graphic or text screen from a file in BLOAD
  2700.        (Microsoft BASIC) or .PCX (Microsoft Paintbrush) format.
  2701.  
  2702.  
  2703.                                        - 69 -
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.        The HyperShell language                       HyperShell Users Guide
  2711.  
  2712.  
  2713.  
  2714.        After display the mouse may be used to select a zone on the screen, or
  2715.        a key may be pressed to choose an option if no mouse is available.
  2716.        The character and zone mappings are defined in a special form of MENU,
  2717.        and selected using a zone selection menu.
  2718.  
  2719.        The `g' action does not reset the screen mode after display, so that
  2720.        graphic screens can be displayed one after the other with no lack of
  2721.        continuity. The `g' action with no parameter resets the display mode
  2722.        to the default text mode, which would otherwise take place the next
  2723.        time the frame display is refreshed.
  2724.  
  2725.        The zone selection menu is specified using a special form of menu
  2726.        call, as follows:-
  2727.  
  2728.          Mmenuname[@]
  2729.  
  2730.        The menu options for a zone selection menu are set up using the
  2731.        graphics preparation facilities described later.
  2732.  
  2733.        An alternative method is to use a script which handles the coordinates
  2734.        of the selection itself.  The `&X' and `&Y' functions return the
  2735.        column number and line number of the mouse cursor when a button was
  2736.        pressed during the last graphic display.  The `&Z' function returns
  2737.        the key pressed.
  2738.  
  2739.        If these coordinates are to be set for other than a graphic display,
  2740.        the `ZG' action can be used, which causes the mouse coordinates to be
  2741.        set.
  2742.  
  2743.        The `Zg' action is also available for a slightly different purpose.
  2744.        This will cause the mouse to be used for selection from the screen
  2745.        currently on display. If a parameter is supplied (eg. Zg#), the screen
  2746.        is assumed to have a high vertical resolution (greater than 200) when
  2747.        calculating the mouse coordinates.  This can be used where some
  2748.        external program is used to display the graphic screen, or possibly
  2749.        when a further selection is needed from a screen displayed using the
  2750.        `g' action.
  2751.  
  2752.        4.4 Advanced features
  2753.  
  2754.        Certain applications demand more control over the display and
  2755.        operation of the hyperfile.
  2756.  
  2757.        A number of advanced control facilities are provided, which are not
  2758.        expected or required to be used for the majority of purposes.  These
  2759.        assume a certain level of programming familiarity, and can readily
  2760.        cause problems for those who try them without fully understanding
  2761.        their function.  As always, a certain amount of trial and error is
  2762.        necessary to get the most out of these.  It is recommended that you do
  2763.        not try these until you are reasonably conversant with the features
  2764.        described above.
  2765.  
  2766.  
  2767.  
  2768.  
  2769.                                        - 70 -
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.        HyperShell Users Guide                        The HyperShell language
  2777.  
  2778.  
  2779.        4.4.1 Display control
  2780.  
  2781.        Direct Positioning
  2782.  
  2783.        During text display in a frame or note (or direct output - see below),
  2784.        the text writing position can be absolutely positioned using the
  2785.        direct positioning flags.  These are similar to the line and column
  2786.        positioning flags, but have more power in that they will change the
  2787.        position regardless of the current position.  This power is at the
  2788.        same time useful and dangerous, as text can easily be overwritten and
  2789.        the text garbled.  The two commands are the equivalents of ~L and ~C,
  2790.        and are as follows:-
  2791.  
  2792.          ~Ynn          set position to line nn
  2793.  
  2794.        and
  2795.  
  2796.          ~Xnn          set position to column nn
  2797.  
  2798.        The ~X flag has the added function of setting the `start' of a width
  2799.        specified by the ~W formatting flag.
  2800.  
  2801.        Indents
  2802.  
  2803.        In a large hyperfile, it can get tedious adding a left margin to every
  2804.        frame.  One way of saving some work is to use the indent formatting
  2805.        flag to set a standard left margin which will be used to offset the
  2806.        text on display in a frame.  The flag takes the form:-
  2807.  
  2808.          ~in
  2809.  
  2810.        where `n' is the indent between 0 (for no indent) and 9, for 9 spaces
  2811.        indent.  This is coded on the line after which you wish the indenting
  2812.        to appear.  On common location for this is at the end of the HEADER
  2813.        item, to set it for the frame text display (and possibly again at the
  2814.        start of the FOOTER to reset it to 0).
  2815.  
  2816.        When an indent is in effect, a line can be temporarily reset to flush
  2817.        left using the direct column positioning flag:-
  2818.  
  2819.          ~X0
  2820.  
  2821.        The indent has its disadvantages.  The integrated environment editor
  2822.        does not show the indent, and so any tabs and direct column settings
  2823.        in the line may cause the edit display to not reflect the appearance
  2824.        of the eventual frame display.
  2825.  
  2826.  
  2827.  
  2828.  
  2829.  
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835.                                        - 71 -
  2836.  
  2837.  
  2838.  
  2839.  
  2840.  
  2841.  
  2842.        The HyperShell language                       HyperShell Users Guide
  2843.  
  2844.  
  2845.        Boxes
  2846.  
  2847.        Having boxes around text can help to enhance the appearance, and to
  2848.        subdivide the display.  Boxes can be drawn within frame and note text
  2849.        using the graphics characters of course, and this is preferable when
  2850.        the box is specific to a frame or note, or within the header or
  2851.        footer.  Many text editors provide box drawing capability, and these
  2852.        can be used to produce the boxes or tables, which are then imported to
  2853.        HyperShell.  Where a box is required around every frame, or where a
  2854.        box is required around `expansion references' there is a dynamic box
  2855.        drawing capability provided by HyperShell.  With this, the top left
  2856.        corner of a box is marked, then at the bottom right corner another
  2857.        flag is coded which causes a box to be drawn.  Thus the following
  2858.        flags have the illustrated effect:-
  2859.  
  2860.          ~a                         +-----------------------+
  2861.                                     |                       |
  2862.                                     |                       |
  2863.                                     |                       |
  2864.                                     |                       |
  2865.                                     |                       |
  2866.                              ~b1    +-----------------------+
  2867.  
  2868.        For a frame display, these can be used with actual margins or
  2869.        specified indent to frame the text.  The HS hyperfile uses this, and
  2870.        should be referred to as an example.
  2871.  
  2872.        Other codes can be used with the box flag to cause a text window to be
  2873.        defined within the box, or without a surrounding box.  Text can then
  2874.        be written into the box, and can scroll without affecting the
  2875.        surrounding display.
  2876.  
  2877.        If a sub-window is set up, text may be output to it using the direct
  2878.        output facilities (see below).  It can also cause unwanted (and often
  2879.        amusing) effects, due to other output trying to appear in the small
  2880.        window.  To avoid this, the `Zr' action is provided to reinstate the
  2881.        full screen window.
  2882.  
  2883.        Direct output
  2884.  
  2885.        Once the frame has been displayed, there seems little that can be done
  2886.        to change what is on display, and it seems awkward to have to redraw
  2887.        the whole frame to change one value on display.  The direct output
  2888.        action has been provided to overcome this apparent restriction. It
  2889.        allows an action, usually in a script, to write straight to the
  2890.        screen.  This action takes the form:-
  2891.  
  2892.          istring
  2893.  
  2894.        where `string' is the string to be displayed.  The string can contain
  2895.        any formatting flags, as used in the frame display, such as colour
  2896.        scheme settings, direct positioning and even references.  The direct
  2897.        positioning flags are nearly always used in this action, unless it
  2898.        follows after another such action.
  2899.  
  2900.  
  2901.                                        - 72 -
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.        HyperShell Users Guide                        The HyperShell language
  2909.  
  2910.  
  2911.  
  2912.        When displaying references in this manner, you should be aware of the
  2913.        following:-
  2914.  
  2915.        1. If you overwrite another reference, the original reference will be
  2916.        selected first always.  Every reference drawn adds to the list and you
  2917.        may hit the limit if you repeatedly output references.
  2918.  
  2919.        2. If the reference is drawn `among' other references, the TAB/SHIFT
  2920.        TAB stepping will not work as expected when it comes to these
  2921.        references.
  2922.  
  2923.        The box display, and the sub-window variants, may also be used after
  2924.        the frame has been drawn, to cause a window to overlay part of the
  2925.        frame display.  This can be used for displaying extra information, or
  2926.        for a number of purposes, including effects (such as wipes or
  2927.        explodes).  In this case, two sets of direct positioning flags are
  2928.        used in the action, with the box start after the first and the box end
  2929.        after the second.
  2930.  
  2931.        Direct input
  2932.  
  2933.        Of course, once you have the capability of outputting anything
  2934.        anywhere, you will want to input from an arbitrary point as well.  The
  2935.        `&i' function is provided for the more adventurous of you, and has the
  2936.        following format:-
  2937.  
  2938.          &i{default}
  2939.  
  2940.        where default is an optional default value which is displayed for
  2941.        editing.  This function allows a string to be input at the current
  2942.        `output' position, as set by the direct output action.  The string
  2943.        entered is returned as the result of the function.
  2944.  
  2945.        Screen saving and showing
  2946.  
  2947.        After the direct output facilities are used to draw a number of boxes
  2948.        containing information on the screen, it is sometimes desirable to
  2949.        clear the information from the screen.  This can be done by refreshing
  2950.        the screen with a `y' action, of course, but another method exists.
  2951.        This uses the screen save area which the `-s' command line flag
  2952.        otherwise uses, to capture the full screen display, and subsequently
  2953.        re-display it.  This is done using the two actions:-
  2954.  
  2955.          ZT             Take copy of screen
  2956.  
  2957.          Zt             Display copy taken with ZT
  2958.  
  2959.        The copy is taken before the direct output of sub-windows and boxes,
  2960.        and shown when the information is no longer required. The re-display
  2961.        is almost instantaneous, and it appears as though the boxes have been
  2962.        `popped down'.
  2963.  
  2964.  
  2965.  
  2966.  
  2967.                                        - 73 -
  2968.  
  2969.  
  2970.  
  2971.  
  2972.  
  2973.  
  2974.        The HyperShell language                       HyperShell Users Guide
  2975.  
  2976.  
  2977.        4.4.2 Program control
  2978.  
  2979.        SHARE directive
  2980.  
  2981.        If we have a number of hyperfiles which use a common HEADER, FOOTER
  2982.        and set of global items, the following directive can be used.
  2983.  
  2984.          .SHARE
  2985.  
  2986.        This is used in secondary hyperfiles in place of the HEADER, FOOTER
  2987.        and global items, and causes that hyperfile to use those items from
  2988.        the primary hyperfile.  A primary hyperfile is the one specified on
  2989.        the command line (or HOME.HYP if no hyperfile is specified).
  2990.  
  2991.        The secondary hyperfiles can be pre-loaded using the action:-
  2992.  
  2993.          ZPfilename
  2994.  
  2995.        Autoreferencing
  2996.  
  2997.        Autoreferencing is the dynamic addition of reference flags to text as
  2998.        it is displayed.  Using autoreferencing, you can view normal text
  2999.        files, and key words and phrases will be highlighted as references
  3000.        which can be selected.  This enables a reference hyperfile to be
  3001.        resident when viewing a technical document file.  There are many other
  3002.        possibilities to the various forms of autoreferencing.
  3003.  
  3004.        The autoreference capabilities provided by HyperShell are as follows:-
  3005.  
  3006.            Autoreference categories       Option
  3007.          +--------------------------------------+
  3008.          | Frame name autoreference      | O41  |
  3009.          | Global note name autoref      | O44  |
  3010.          | Application Specified autoref | O42  |
  3011.          +--------------------------------------+
  3012.  
  3013.            Autoreference targets          Option
  3014.          +--------------------------------------+
  3015.          | Files displayed by `T' action | O*40 |
  3016.          | As above plus frame texts     | O*41 |
  3017.          +--------------------------------------+
  3018.  
  3019.        The settings for option 4 may be added together to form a combination
  3020.        of autoreferencing.  If option 4 is set to 0, no autoreferencing takes
  3021.        place.
  3022.  
  3023.        Frame name autoreference should only be specified for hyperfiles with
  3024.        a low number of frames (possibly up to 100 frames), as it slows down
  3025.        the display depending on the number of frames.
  3026.  
  3027.        Global note name autoreference is very useful for reference and
  3028.        tutorial applications, where a number of terms can be explained in
  3029.        global notes, and these can be popped up for an explanation.
  3030.  
  3031.  
  3032.  
  3033.                                        - 74 -
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.        HyperShell Users Guide                        The HyperShell language
  3041.  
  3042.  
  3043.        Application specified autoreference is a more general form of
  3044.        autoreferencing, and is specified for the current hyperfile using the
  3045.        ZA action.  This takes the following form:-
  3046.  
  3047.          ZAkey:action
  3048.  
  3049.        The `key' part of this is of the form:-
  3050.  
  3051.          Astring
  3052.  
  3053.        Where `A' is the reference type letter, and `string' is the key string
  3054.        to be matched in the displayed text.  The `:action' part specifies the
  3055.        action parameter to be added to the reference.  The `:action' part can
  3056.        be omitted, in which case the reference is substituted without a
  3057.        parameter part.
  3058.  
  3059.        For example:-
  3060.  
  3061.          ZAMIndex
  3062.  
  3063.        Will replace the string `Index' in the displayed text with
  3064.        `~MIndex~E'.  When selected, this will display the global menu
  3065.        `Index'.
  3066.  
  3067.        Or:-
  3068.  
  3069.          ZAAbell:ZB
  3070.  
  3071.        Will replace the string `bell' with `~Abell~PZB~E'.  When selected,
  3072.        this will sound the bell on the PC.
  3073.  
  3074.        Uses for this form of autoreferencing are limited only by your
  3075.        imagination.
  3076.  
  3077.        Unget character
  3078.  
  3079.        One of the more useful tricks in HyperShell is the use of the ZU
  3080.        action.  This action `ungets' a character so that it will appear as
  3081.        though that character has been pressed.  This takes the form:-
  3082.  
  3083.          ZUc
  3084.  
  3085.        Where `c' is the character to `unget'.
  3086.  
  3087.        For example, suppose we wish to activate a specific field on an input
  3088.        form.  If we provide a key mapping for each input field, we just have
  3089.        to unget the appropriate key to select that field.
  3090.  
  3091.  
  3092.  
  3093.  
  3094.  
  3095.  
  3096.  
  3097.  
  3098.  
  3099.                                        - 75 -
  3100.  
  3101.  
  3102.  
  3103.  
  3104.  
  3105.  
  3106.        The HyperShell language                       HyperShell Users Guide
  3107.  
  3108.  
  3109.        Immediate reference
  3110.  
  3111.        One reference on a frame or note display may be flagged as an
  3112.        `immediate' reference.  This will be selected automatically after the
  3113.        frame or note text has been displayed.  This is done by including the
  3114.        sequence ~Q after the complete reference sequence for the reference to
  3115.        be selected.
  3116.  
  3117.        This may be used for many purposes, but the most common would be to
  3118.        select the first input field on a form frame, and therefore put the
  3119.        frame into a data input mode automatically on entry.
  3120.  
  3121.          [n]  Name: ~I$n~W20~PVn%s;I~Kn~E~Q
  3122.  
  3123.        The immediate reference flag may also be used with an `invisible'
  3124.        reference. This has a zero length reference string and does not
  3125.        therefore permit manual selection.  This could be placed in the header
  3126.        or footer to, for instance, write a log file of frames visited.  It
  3127.        can also be used to pop up a note or a menu on moving to a frame.  The
  3128.        following writes the frame name to the current output file (this could
  3129.        be included in the HEADER text).
  3130.  
  3131.          ~A~PW$1~E~Q
  3132.  
  3133.        4.4.3 Communicating with other programs
  3134.  
  3135.        When running your program from HyperShell, it would sometimes be
  3136.        useful to pass information back to HyperShell.  If you write your own
  3137.        programs, this can be possible, using the following technique.
  3138.  
  3139.        A function is provided which returns a string representing the
  3140.        segment:offset address of a variable:-
  3141.  
  3142.          &vV                - where V is the variable name
  3143.  
  3144.        This address should be placed in the command line of the program which
  3145.        you are running.  This can then allow it to access the variable
  3146.        directly.  A number of such addresses can be supplied.
  3147.  
  3148.        The variable to receive the data MUST be set up in HyperShell to a
  3149.        length sufficient for the data to be loaded into it, using any data
  3150.        string e.g.
  3151.  
  3152.          VV-----------------
  3153.  
  3154.        The variable, after the call to the program, will contain the value
  3155.        set by that program.
  3156.  
  3157.        It may be reused on subsequent calls, and may be freed as normal when
  3158.        no longer required e.g.
  3159.  
  3160.          VV
  3161.  
  3162.  
  3163.  
  3164.  
  3165.                                        - 76 -
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.        HyperShell Users Guide                        The HyperShell language
  3173.  
  3174.  
  3175.        4.4.4 String conversions
  3176.  
  3177.        Processing strings input from the user, or from a file, is a common
  3178.        requirement in some applications.  Computer Aided Instruction
  3179.        applications often process a reply to a question before testing it
  3180.        against possible answers.
  3181.  
  3182.        There is an additional string function to perform explicit conversions
  3183.        on strings:-
  3184.  
  3185.          &#vstring
  3186.  
  3187.        This converts variable `v' according to `string'
  3188.  
  3189.        The `according to' string is a string of directives to show the
  3190.        conversion required.
  3191.  
  3192.           String conversion directives
  3193.          +---------------------------------------------------+
  3194.          | l  | convert to lowercase                         |
  3195.          | u  | convert to uppercase                         |
  3196.          | s  | strip leading, trailing and extra spaces     |
  3197.          | tv | translate according to variable v            |
  3198.          | rv | remove characters as specified in variable v |
  3199.          +---------------------------------------------------+
  3200.  
  3201.        The translate variable will contain pairs of characters, the first of
  3202.        a pair being the character to translate from, and the second character
  3203.        being the character to translate to.
  3204.  
  3205.        The remove variable simply contains those characters which you want to
  3206.        remove from the string.
  3207.  
  3208.        Each directive can be made conditional by preceding it with:-
  3209.  
  3210.          ic
  3211.  
  3212.        where c is any condition code letter. eg.
  3213.  
  3214.          i3rr
  3215.  
  3216.        removes characters specified in variable `r' if frame-local flag 3 is
  3217.        set
  3218.  
  3219.        Directives and conditional directives can be combined in a single
  3220.        string:-
  3221.  
  3222.          ls - convert to lowercase and remove spaces
  3223.  
  3224.        For example, if variable `x' contains a response string, to convert
  3225.        this to lowercase and remove extraneous spaces, the following action
  3226.        is issued:-
  3227.  
  3228.          Vx&#xls
  3229.  
  3230.  
  3231.                                        - 77 -
  3232.  
  3233.  
  3234.  
  3235.  
  3236.  
  3237.  
  3238.        The HyperShell language                       HyperShell Users Guide
  3239.  
  3240.  
  3241.  
  3242.        The usual method of setting up for complex string processing is to set
  3243.        the translation and exclusion characters in the SETUP script.  For
  3244.        example, to set up variable `t' to hold the translation for lowercase
  3245.        vowels to uppercase, the action would be:-
  3246.  
  3247.          VtaAeEiIoOuU
  3248.  
  3249.        The `remove' variable may also be set up here.  A complication arises
  3250.        if you want to remove a `$' or `;' or `|' character.  These would
  3251.        normally cause problems in a simple variable assignment action, and it
  3252.        has to be done by use of pseudo variables, or by first setting up a
  3253.        variable to hold the special characters:-
  3254.  
  3255.          Vd&C36  - set dollar in `d'
  3256.  
  3257.        Then, to assign the string `.,:;|@$' to variable `r':-
  3258.  
  3259.          Vr.,:$,$!@$d
  3260.  
  3261.        Also note the special characters which cannot be immediately after the
  3262.        variable name (&%@!?) - these should be put further along the string.
  3263.  
  3264.        4.4.5 Formatting Patterns
  3265.  
  3266.        Earlier, we learnt how a formatting pattern could be added to an
  3267.        action modifier to format the result before it was applied to the
  3268.        action.  Formatting pattern strings consist of the string expected as
  3269.        a parameter, with all occurrences of the chosen string represented by
  3270.        the token `%s'.  Up to three tokens can be specified.  As well as the
  3271.        more trivial example introduced earlier, this facility can be used for
  3272.        more complex formatting.  The token can be coded in different ways for
  3273.        different format effects.
  3274.  
  3275.           Format token structure
  3276.          +-------------------------------------------------+
  3277.          | %{-}{nn){.mm}s                                  |
  3278.          |  | |       |                                    |
  3279.          |  | | maximum length (truncated at right end)    |
  3280.          |  | minimum length (right aligned, space fill)   |
  3281.          |  left align (else right align)                  |
  3282.          +-------------------------------------------------+
  3283.  
  3284.        For example:-
  3285.  
  3286.          %s       full string as supplied
  3287.          %8s      string to minimum length of 8, right aligned
  3288.          %-8s     ditto, left aligned
  3289.          %.23s    string to maximum length of 23
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.                                        - 78 -
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.        HyperShell Users Guide                        The HyperShell language
  3305.  
  3306.  
  3307.        4.4.6 Pattern match
  3308.  
  3309.        In many applications, it is desirable to be able to compare a variable
  3310.        against a text `pattern'.  This can be used for validation of fields,
  3311.        for instance to see if a date is in the correct format.  The pattern
  3312.        match facility is available in HyperShell in a number of places, as
  3313.        follows:-
  3314.  
  3315.           Pattern match availability
  3316.          +----------------------------------------+
  3317.          | Variable comparisons                   |
  3318.          | Menu table lookup                      |
  3319.          | Title and text searches                |
  3320.          | String search in file display          |
  3321.          +----------------------------------------+
  3322.  
  3323.        Pattern specification
  3324.  
  3325.        The `pattern' can contain literal characters, ie. actual characters
  3326.        which must be present, and various `metacharacters' which represent
  3327.        patterns and classes of character:-
  3328.  
  3329.           Pattern metacharacters
  3330.          +------------------------------------------------------+
  3331.          |<       | at start - match start of string            |
  3332.          |>       | at end - match end of string                |
  3333.          |?       | match any character                         |
  3334.          |_       | match one or more space or TAB characters   |
  3335.          |(a1/a2) | match a1 or a2 (optional if only one)       |
  3336.          |[abc]   | match `a', `b' or `c'                       |
  3337.          |[^abc]  | match any character but `a','b' or `c'      |
  3338.          |[x-y]   | match any character in range x to y         |
  3339.          |{       | start of word                               |
  3340.          |}       | end of word                                 |
  3341.          |x#      | zero or more of character/subexpression x   |
  3342.          |x+      | one or more of character/subexpression x    |
  3343.          |*       | any string (equivalent to ?#)               |
  3344.          |\x      | character `x' (for literal metacharacters)  |
  3345.          +------------------------------------------------------+
  3346.  
  3347.        Examples of patterns
  3348.  
  3349.          [a-zA-Z]           Match any letter
  3350.          [a-zA-Z]+          Match an alphabetic string
  3351.          [0-9]+             Match a numeric string
  3352.          [aeiou]            Match lowercase vowels
  3353.          (perhaps)          Match optional string `perhaps'
  3354.          (cat/dog)(s)       Match `cat' or `cats' or `dog' or `dogs'
  3355.          ((pine)apple/grape(fruit)) `apple','pineapple','grape', or
  3356.                             `grapefruit'
  3357.          {and}              Match the whole word and (not brandy)
  3358.          <This              The word This at the start of a line
  3359.                             or string
  3360.          \\                 Match the '\' character
  3361.  
  3362.  
  3363.                                        - 79 -
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.        The HyperShell language                       HyperShell Users Guide
  3371.  
  3372.  
  3373.          cat*dog            Match string with cat and dog in that order
  3374.          Th[^e]             This, That, Those etc, but not The
  3375.          -{                 A hyphen immediately before a word
  3376.          <????>             Any four character string
  3377.          [A-Z][A-Z][0-9]+_[0-9][A-Z][A-Z]   A british postcode??
  3378.  
  3379.        Variable comparison
  3380.  
  3381.        The normal variable comparison can be made to perform a pattern match
  3382.        in addition to its other comparisons.  An extended comparison is
  3383.        triggered by variable `~' being set.
  3384.  
  3385.        The value of variable `~' is used to contain a string conversion
  3386.        specification, or another character such as `#' if no conversion is
  3387.        required.  The comparison translates both operands according to the
  3388.        conversion specified in variable `~', then if the second operand
  3389.        starts with a `^' character, the rest of that operand is treated as a
  3390.        pattern match string, otherwise a case sensitive comparison is
  3391.        performed.
  3392.  
  3393.        The variable comparison will then perform a pattern match comparison,
  3394.        setting condition code `m' is the match succeeded or code `f' if the
  3395.        match failed.  If variable `~' is NOT set, the condition code `f' will
  3396.        be returned in all cases, even when code `e' is set.
  3397.  
  3398.        The conversions performed do not affect the value of the variable, and
  3399.        are effective for the comparison only.
  3400.  
  3401.        Menu table lookup
  3402.  
  3403.        The pattern match capability can also be used in a menu lookup table.
  3404.  
  3405.          @m[string]
  3406.  
  3407.        NOTE:- @m,@M,@F are all handled this way.
  3408.  
  3409.        This converts the string according to the variable `~' (if this has a
  3410.        value), and then compares the string against each key in the menu.  If
  3411.        the pattern starts with a `^' character, it does a pattern match with
  3412.        rest of string as a pattern else it does a case sensitive string
  3413.        comparison, returning the action string if it matches.  If the pattern
  3414.        is the character `*' it returns the action string.
  3415.  
  3416.        NOTE: Any conversions specified by the variable `~' will be applied
  3417.        against the pattern string as well as the comparator string.  This
  3418.        means that case conversions, space removal, punctuation removal and
  3419.        diacritic conversions will be performed.
  3420.  
  3421.        Thus a variable containing characters to be removed must not contain
  3422.        any `pattern match' metacharacters used in the pattern strings,
  3423.        otherwise these will be removed before a pattern match, which will
  3424.        produce unexpected effects.
  3425.  
  3426.  
  3427.  
  3428.  
  3429.                                        - 80 -
  3430.  
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436.        HyperShell Users Guide                        The HyperShell language
  3437.  
  3438.  
  3439.        The menu table lookup can save you a lot of effort, by reducing a
  3440.        series of comparisons to a simple table.  The lookup menu has pattern
  3441.        strings which are handled like the additional variable comparison
  3442.        second operand.  In this case, the action string is returned if the
  3443.        comparison succeeds, else it passes to the next in the table.
  3444.  
  3445.        For example, supposing we can have the a number of potential answers,
  3446.        which have varying degrees of correctness:-
  3447.  
  3448.          +---------------------------------------+
  3449.          |.MENU school                           |
  3450.          |^(The boy/He) likes (the) school|C     |
  3451.          |^(The boy/He) loves (the) school|N     |
  3452.          |^(The boy/He) prefers (the) school|N   |
  3453.          |^(The boy/He) hates (the) school|W     |
  3454.          |^(The boy/He) dislikes (the) school|W  |
  3455.          |*|H                                    |
  3456.          +---------------------------------------+
  3457.  
  3458.        This returns `C' if the answer is correct, `N' if it is nearly
  3459.        correct, `W' if it is wrong, and `H' if it is hopelessly wrong.  We
  3460.        could then have a script to handle the input and testing:-
  3461.  
  3462.          +----------------------------------------------+
  3463.          |.SCRIPT test                                  |
  3464.          |-- ask question, get reply in `i'             |
  3465.          |Vi?does he like school                        |
  3466.          |-- look up `correctness' and branch           |
  3467.          |J@Mschool[$i]                                 |
  3468.          |LH                                            |
  3469.          |PThat answer is hopeless                      |
  3470.          |JCORR                                         |
  3471.          |LC                                            |
  3472.          |PWell done, that is correct                   |
  3473.          |-- add score                                  |
  3474.          |Vs=s+10                                       |
  3475.          |JNEXT                                         |
  3476.          |LN                                            |
  3477.          |PThat is nearly correct                       |
  3478.          |Vs=s+5                                        |
  3479.          |JCORR                                         |
  3480.          |LW                                            |
  3481.          |PThat is wrong, but you have the right idea   |
  3482.          |Vs=s+1                                        |
  3483.          |LCORR                                         |
  3484.          |-- display correct answer                     |
  3485.          |pHe likes school                              |
  3486.          |LNEXT                                         |
  3487.          +----------------------------------------------+
  3488.  
  3489.  
  3490.  
  3491.  
  3492.  
  3493.  
  3494.  
  3495.                                        - 81 -
  3496.  
  3497.  
  3498.  
  3499.  
  3500.  
  3501.  
  3502.        The HyperShell language                       HyperShell Users Guide
  3503.  
  3504.  
  3505.        Note that the result of the menu lookup can be used to control almost
  3506.        anything, as the returned string can be used as the parameter to any
  3507.        action. Here it is used as a label to jump to. It could also be used
  3508.        to return the name of a note to display, or of a frame to branch to
  3509.        next.
  3510.  
  3511.        Patterns in searching
  3512.  
  3513.        The pattern match facilities can be used in the search operations
  3514.        available from the dynamic menus @S,@s,@X,@x.  Also the search
  3515.        operation under the `T' (type file) action can make use of patterns in
  3516.        searches.
  3517.  
  3518.        To specify that a pattern search is to be done, prefix the search
  3519.        string with the `^' sign. It will then be interpreted as a pattern
  3520.        match search, in accordance with the rules for patterns given above.
  3521.  
  3522.          A@S^[0-9]#     - Search for titles with numbers in them
  3523.  
  3524.        4.4.7 Character input translation
  3525.  
  3526.        In computer assisted language learning (CALL) applications for
  3527.        languages with extended character sets which include diacritics
  3528.        (accented characters), the entry of these extra characters can prove a
  3529.        problem.  Whilst alternative keyboard mappings are available with
  3530.        MSDOS, it is not always convenient to use these, and the key caps will
  3531.        not show the correct symbols if the keyboard is not intended for the
  3532.        language being used.
  3533.  
  3534.        A number of ways of entering these special characters are supported by
  3535.        different applications.  HyperShell provides one method for supporting
  3536.        these, in the form of a character translation table.  This capability
  3537.        allows string input characters (those input on the bottom line or to
  3538.        input fields) to have a translation mapping applied against them.
  3539.  
  3540.        This is usually used to map certain ALT shifted keys, or function
  3541.        keys, to the accented characters.
  3542.  
  3543.        Specification:-
  3544.  
  3545.        General key settings KG8 and KG9 provide the `from' and `to' tables of
  3546.        characters.  Whenever a character in the `from' string is input, it is
  3547.        translated to the corresponding character in the `to' string.  Thus,
  3548.        in a simple case, to map the keys `%&*' to produce `!=^' characters,
  3549.        the following settings are used:-
  3550.  
  3551.          KG8%&*
  3552.          KG9!=^
  3553.  
  3554.        The two mapping strings must be the same length or results will be
  3555.        unpredictable.
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.                                        - 82 -
  3562.  
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568.        HyperShell Users Guide                        The HyperShell language
  3569.  
  3570.  
  3571.        The `from' string specifications can be entered directly from
  3572.        keyboard, and the `to' strings can be entered using the ALT key with
  3573.        the numeric keypad to enter the extended character numeric code.  The
  3574.        values of these are given in the appendix.
  3575.  
  3576.        The mappings do not have any effect on single keystroke inputs, such
  3577.        as function keys, menu selections, reference key mappings etc.
  3578.  
  3579.        The character input translation can also be used for stopping the
  3580.        input of certain characters by translating them to a character which
  3581.        is rejected during string input, such as TAB (ASCII 9).
  3582.  
  3583.        4.4.8 Timing and timeouts
  3584.  
  3585.        Timing is an important feature of Computer Aided Instruction
  3586.        applications.  HyperShell provides a number of facilities to help with
  3587.        this.
  3588.  
  3589.        Single character input with timeout
  3590.  
  3591.        The `&G' function takes the supplied numeric string as a timeout
  3592.        period in hundredths of a second.  It then awaits a key depression and
  3593.        either returns the character pressed, or a null string if the timeout
  3594.        occurs.  eg.
  3595.  
  3596.          Vn&G300
  3597.  
  3598.        This waits 3 seconds for a key press and loads it into variable `n',
  3599.        or times out.
  3600.  
  3601.        The character input can be fed back as key input using the `unget'
  3602.        action (ZU), for use in selections from frame displays etc.  For
  3603.        example, a multi-choice frame can be set up containing a number of key
  3604.        mappings for the choices.  A script is run on entering the frame which
  3605.        issues the following sequence of actions:-
  3606.  
  3607.          +--------------------------------------+
  3608.          |.SCRIPT get timeout                   |
  3609.          |-- Get key with timeout of 4 seconds  |
  3610.          |Vn&G400                               |
  3611.          |-- If timeout, branch                 |
  3612.          |jbTIMEOUT                             |
  3613.          |-- else put key back and continue     |
  3614.          |ZUn                                   |
  3615.          |q                                     |
  3616.          |-- Tell them                          |
  3617.          |ZB;PSorry, your time is up            |
  3618.          |-- Go to next question                |
  3619.          |F+                                    |
  3620.          +--------------------------------------+
  3621.  
  3622.        Time of day
  3623.  
  3624.        The `&H' function returns the time of day as hundredths of
  3625.  
  3626.  
  3627.                                        - 83 -
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.        The HyperShell language                       HyperShell Users Guide
  3635.  
  3636.  
  3637.        a second.  This can be used to time long periods of activity, or to
  3638.        write a record to a log each time a frame is selected.
  3639.  
  3640.        Delta time
  3641.  
  3642.        The `&J' function returns the difference in time since the last call
  3643.        to function `&J', function `&G', function `&H' or the last frame
  3644.        display, in hundredths of a second.  It can be used to time certain
  3645.        events, such as the time taken to select from a menu or a frame.
  3646.  
  3647.        Delay in displayed text
  3648.  
  3649.        The `wait' flag causes a delay in seconds before proceeding with the
  3650.        display. This is used to allow the user to read part of the text
  3651.        before showing subsequent text. eg. to wait 3 seconds in the display,
  3652.        the following flag is inserted:-
  3653.  
  3654.          ~w3
  3655.  
  3656.        Teletype mode display
  3657.  
  3658.        The teletype flag causes text to be slowly displayed as though by an
  3659.        old fashioned teletype.  The flag acts as a toggle, and is effective
  3660.        for the text following it on the line only. eg.
  3661.  
  3662.          fast text ~d slow text ~d fast text
  3663.  
  3664.        4.5 Hints, Tips and Tricks
  3665.  
  3666.        This section offers advice on some of the obstacles you may encounter
  3667.        whilst using HyperShell and describes ways of getting around them. It
  3668.        also describes some useful tricks that can be used to utilise the
  3669.        power of the system in simple ways.
  3670.  
  3671.        4.5.1 Special characters
  3672.  
  3673.        There is always a problem with getting special characters to appear
  3674.        where you want them, and to get them translated when you want them to.
  3675.        The sections later in this chapter describing the processing order for
  3676.        various stages should help in this process, but the following list is
  3677.        given of the more common problems.
  3678.  
  3679.        Frame and note displays
  3680.  
  3681.        To display a dollar sign or a flag character `~' in frame or note
  3682.        text, simply code two dollars or flags together.
  3683.  
  3684.        To have a variable token in a reference action string expand when a
  3685.        reference is selected rather than when it is displayed, code two
  3686.        dollar signs.
  3687.  
  3688.        To have a variable which contains another variable token which can
  3689.        expand in frame text, use a named variable for the container.
  3690.  
  3691.  
  3692.  
  3693.                                        - 84 -
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.        HyperShell Users Guide                        The HyperShell language
  3701.  
  3702.  
  3703.        Action strings
  3704.  
  3705.        To map a key to an action string which contains a variable token to be
  3706.        expanded when the key is pressed, code two dollar signs.
  3707.  
  3708.        To use an action modifier character at the start of an action
  3709.        parameter, code a `&W' function before the parameter.
  3710.  
  3711.        To get a `;' character or a `|' character into an action parameter,
  3712.        use the pseudo variables $, and $!.
  3713.  
  3714.        To include control characters and other special characters, set up a
  3715.        variable containing the character using the &C function to supply the
  3716.        ASCII value of the character, then use the variable token in the
  3717.        action string instead of the character.
  3718.  
  3719.        4.5.2 Display tricks
  3720.  
  3721.        Local key mappings
  3722.  
  3723.        To get extra key mappings into a frame display, without having a
  3724.        visible reference, use a null reference string:-
  3725.  
  3726.          ~A~Paction~Kk~E
  3727.  
  3728.        This will map `k' to `action'. These can appear somewhere in the frame
  3729.        text, preferably at the end of a line or in a blank line, and
  3730.        preferably together if there are more than one.
  3731.  
  3732.        Frame revisits
  3733.  
  3734.        To display a frame for information, and return on any key press, code
  3735.        the following into the frame text:-
  3736.  
  3737.          ~A~PP;B~E~Q
  3738.  
  3739.        4.5.3 General
  3740.  
  3741.        Staged backtrack
  3742.  
  3743.        To hold points on the backtrack to unwind to, hold the current
  3744.        backtrack level in a variable:-
  3745.  
  3746.          VL$6
  3747.  
  3748.        And unwind using:-
  3749.  
  3750.          b$L
  3751.  
  3752.        Disabling Function keys
  3753.  
  3754.        To do this, simply map the function keys to a null string.  So to
  3755.        disable ALL the function keys, do the following:-
  3756.  
  3757.  
  3758.  
  3759.                                        - 85 -
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.        The HyperShell language                       HyperShell Users Guide
  3767.  
  3768.  
  3769.          KF1;KF2;KF3;KF4;KF5;KF6;KF7;KF8;KF9;KF0
  3770.  
  3771.        Also, you will need to map the ESCape key to a null string or
  3772.        something else, e.g.
  3773.  
  3774.          KH4MMy Menu
  3775.  
  3776.        This pops up a menu called `My Menu' instead of the control menu.
  3777.  
  3778.        Clear message line
  3779.  
  3780.        Simply issue the action
  3781.  
  3782.          p
  3783.  
  3784.        Extended matching frames list
  3785.  
  3786.        To give a contents list of matching frames from more than one
  3787.        hyperfile after an extended search:-
  3788.  
  3789.          O*63
  3790.          A@X
  3791.  
  3792.        Automatic pick and search
  3793.  
  3794.        To configure a key to perform an automatic `pick and search', whereby
  3795.        the mouse cursor can be positioned over a word, a key pressed, and a
  3796.        search performed in the text for that word, the following action can
  3797.        be used
  3798.  
  3799.          K#pA@X&P
  3800.  
  3801.        This maps the `p' key to the pick and search action. Other search
  3802.        types can be used instead.
  3803.  
  3804.        It is also possible to map a key to show the first action associated
  3805.        with a displayed reference. This may be done as follows, which maps
  3806.        the `r' key to an action which displays the reference action on the
  3807.        bottom line.
  3808.  
  3809.          K#rp&Q
  3810.  
  3811.        The general key mapping 1 defines the action which will happen if the
  3812.        RETURN key or the LEFT mouse button is pressed when the mouse cursor
  3813.        is not over a reference.  This could be mapped to the automatic pick
  3814.        and search to provide a different form of cross referencing.  For
  3815.        example, it could be mapped to do a title search.
  3816.  
  3817.          KG1A@S&P
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.                                        - 86 -
  3826.  
  3827.  
  3828.  
  3829.  
  3830.  
  3831.  
  3832.        HyperShell Users Guide                        The HyperShell language
  3833.  
  3834.  
  3835.        4.5.4 Keeping organised
  3836.  
  3837.        It is easy in a complicated application, when you only have a limited
  3838.        number of variables, to accidentally re-use one.  This can cause
  3839.        problems for you, as the application will not work as expected.  Also,
  3840.        the key mappings can cause similar problems if you have global
  3841.        mappings as well as key mappings for references.
  3842.  
  3843.        Application flags, local flags, option settings and other items which
  3844.        can conflict are all potential problem areas.
  3845.  
  3846.        The answer to these problems is to keep a chart of variables, key
  3847.        mappings, flags etc. with their usage written alongside.  This will
  3848.        allow you to quickly determine if they have been used before.
  3849.  
  3850.        To keep things really tidy you could set up a REMARK which contained
  3851.        the chart, within the hyperfile.  This would help you when you
  3852.        modified the hyperfile at a later date.
  3853.  
  3854.        4.6 Processing flow
  3855.  
  3856.        These sections give a guide as to how certain processing stages
  3857.        operate, and are intended to help you understand how the system
  3858.        operates.  Note interaction is similar to frame interaction.  List
  3859.        interaction has similarities also, but differs in many respects.
  3860.  
  3861.        4.6.1 Initialisation
  3862.  
  3863.          determine date format
  3864.          determine adaptor type
  3865.          process command line flags and set run options
  3866.          if filename not supplied, use HOME
  3867.          collect bits of frame name together from remaining arguments
  3868.                   on command line and join together
  3869.          set up monochrome attributes if mono adaptor or -h specified
  3870.          set up default mappings
  3871.          save screen if -s specified
  3872.          call config initialisation - read HYPSHELL.CFG
  3873.          load main hyperfile
  3874.                  if cannot open it - popup message and exit
  3875.          run SETUP script if present
  3876.          if -r or -n specified, run RESTART.HSF script if present
  3877.          if frame not displayed already,
  3878.              if frame name supplied on command line, display it
  3879.               else display first frame in hyperfile
  3880.          enter main interaction stage
  3881.  
  3882.        4.6.2 Frame display
  3883.  
  3884.          Locate frame
  3885.          get frame name,title,date,time and memory variables
  3886.          for header text, frame text, footer text
  3887.              expand variable tokens
  3888.              display text, interpreting flags
  3889.  
  3890.  
  3891.                                        - 87 -
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898.        The HyperShell language                       HyperShell Users Guide
  3899.  
  3900.  
  3901.        4.6.3 Interaction (after frame display)
  3902.  
  3903.          a)
  3904.            if immediate action specified, goto b)
  3905.            accept input
  3906.            if control key, get mapped action, goto b)
  3907.            if RETURN / LEFT BUTTON,
  3908.               if over reference,
  3909.                    get action string, go to b)
  3910.               else
  3911.                    do default action (ie. KG... mapping)
  3912.            if key mapped globally, get action, goto b)
  3913.            if key mapped in frame display, get action, goto b)
  3914.            return to a)
  3915.          b)
  3916.            do action processing on action string
  3917.            return to a)
  3918.  
  3919.        4.6.4 Action string processing
  3920.  
  3921.          a)
  3922.            if it has a `;' in it
  3923.               save bit from after first `;' for later
  3924.               truncate at `;'
  3925.          b)
  3926.            if it has a `|' in it, strip pattern string for later
  3927.            locate any action modifier character in pos 2 or 3
  3928.             expand variables from modifier position or pos 2 onwards
  3929.             process action modifier (for dynamic menus look for
  3930.             further action modifier and do b) through c) on it.)
  3931.            apply pattern string to resultant line
  3932.            expand variables in resultant line
  3933.          c)
  3934.            handle action
  3935.            if further action to do, return to a)
  3936.            if bit saved from a) go back to a)
  3937.            return to caller
  3938.  
  3939.  
  3940.  
  3941.  
  3942.  
  3943.  
  3944.  
  3945.  
  3946.  
  3947.  
  3948.  
  3949.  
  3950.  
  3951.  
  3952.  
  3953.  
  3954.  
  3955.  
  3956.  
  3957.                                        - 88 -
  3958.  
  3959.  
  3960.  
  3961.